From aafe6e0f595ae7166cb9633f869de8a0270aa44c Mon Sep 17 00:00:00 2001 From: gmarek Date: Thu, 4 May 2017 15:19:08 +0200 Subject: [PATCH] Make Daemons tolerate NoExecute taints correctly Kubernetes-commit: 9ac920be27d1e8d6dc0cd61028612eb0de9028c5 --- pkg/api/v1/helpers.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/api/v1/helpers.go b/pkg/api/v1/helpers.go index 01f4ef470..82d086de8 100644 --- a/pkg/api/v1/helpers.go +++ b/pkg/api/v1/helpers.go @@ -276,10 +276,10 @@ const ( AffinityAnnotationKey string = "scheduler.alpha.kubernetes.io/affinity" ) -// Tries to add a toleration to annotations list. Returns true if something was updated -// false otherwise. -func AddOrUpdateTolerationInPod(pod *Pod, toleration *Toleration) (bool, error) { - podTolerations := pod.Spec.Tolerations +// AddOrUpdateTolerationInPodSpec tries to add a toleration to the toleration list in PodSpec. +// Returns true if something was updated, false otherwise. +func AddOrUpdateTolerationInPodSpec(spec *PodSpec, toleration *Toleration) (bool, error) { + podTolerations := spec.Tolerations var newTolerations []Toleration updated := false @@ -300,10 +300,16 @@ func AddOrUpdateTolerationInPod(pod *Pod, toleration *Toleration) (bool, error) newTolerations = append(newTolerations, *toleration) } - pod.Spec.Tolerations = newTolerations + spec.Tolerations = newTolerations return true, nil } +// AddOrUpdateTolerationInPod tries to add a toleration to the pod's toleration list. +// Returns true if something was updated, false otherwise. +func AddOrUpdateTolerationInPod(pod *Pod, toleration *Toleration) (bool, error) { + return AddOrUpdateTolerationInPodSpec(&pod.Spec, toleration) +} + // MatchToleration checks if the toleration matches tolerationToMatch. Tolerations are unique by , // if the two tolerations have same combination, regard as they match. // TODO: uniqueness check for tolerations in api validations.