Merge pull request #42964 from k82cn/update_defalt_toleration_sec

Automatic merge from submit-queue (batch tested with PRs 44084, 42964)

Updated AddOrUpdateTolerationInPod to return bool only.

Updated AddOrUpdateTolerationInPod to return bool only, as there's no case to generate error (the error was used for annotation, it'll not return error after moving to field); and also update admission & daemonset accordingly.
This commit is contained in:
Kubernetes Submit Queue
2017-04-05 20:45:20 -07:00
committed by GitHub
6 changed files with 20 additions and 34 deletions

View File

@@ -97,29 +97,21 @@ func (p *plugin) Admit(attributes admission.Attributes) (err error) {
}
if !toleratesNodeNotReady {
_, err := api.AddOrUpdateTolerationInPod(pod, &api.Toleration{
api.AddOrUpdateTolerationInPod(pod, &api.Toleration{
Key: metav1.TaintNodeNotReady,
Operator: api.TolerationOpExists,
Effect: api.TaintEffectNoExecute,
TolerationSeconds: defaultNotReadyTolerationSeconds,
})
if err != nil {
return admission.NewForbidden(attributes,
fmt.Errorf("failed to add default tolerations for taints `notReady:NoExecute` and `unreachable:NoExecute`, err: %v", err))
}
}
if !toleratesNodeUnreachable {
_, err := api.AddOrUpdateTolerationInPod(pod, &api.Toleration{
api.AddOrUpdateTolerationInPod(pod, &api.Toleration{
Key: metav1.TaintNodeUnreachable,
Operator: api.TolerationOpExists,
Effect: api.TaintEffectNoExecute,
TolerationSeconds: defaultUnreachableTolerationSeconds,
})
if err != nil {
return admission.NewForbidden(attributes,
fmt.Errorf("failed to add default tolerations for taints `notReady:NoExecute` and `unreachable:NoExecute`, err: %v", err))
}
}
return nil
}