mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-02 17:57:33 +00:00
remove pod toleration toleration seconds mutation
This commit is contained in:
@@ -3100,10 +3100,11 @@ func validateOnlyAddedTolerations(newTolerations []core.Toleration, oldToleratio
|
|||||||
allErrs := field.ErrorList{}
|
allErrs := field.ErrorList{}
|
||||||
for _, old := range oldTolerations {
|
for _, old := range oldTolerations {
|
||||||
found := false
|
found := false
|
||||||
old.TolerationSeconds = nil
|
oldTolerationClone := old.DeepCopy()
|
||||||
for _, new := range newTolerations {
|
for _, newToleration := range newTolerations {
|
||||||
new.TolerationSeconds = nil
|
// assign to our clone before doing a deep equal so we can allow tolerationseconds to change.
|
||||||
if reflect.DeepEqual(old, new) {
|
oldTolerationClone.TolerationSeconds = newToleration.TolerationSeconds // +k8s:verify-mutation:reason=clone
|
||||||
|
if reflect.DeepEqual(*oldTolerationClone, newToleration) {
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -3987,6 +3988,9 @@ func ValidatePodUpdate(newPod, oldPod *core.Pod, opts PodValidationOptions) fiel
|
|||||||
allErrs = append(allErrs, field.Invalid(specPath.Child("activeDeadlineSeconds"), newPod.Spec.ActiveDeadlineSeconds, "must not update from a positive integer to nil value"))
|
allErrs = append(allErrs, field.Invalid(specPath.Child("activeDeadlineSeconds"), newPod.Spec.ActiveDeadlineSeconds, "must not update from a positive integer to nil value"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow only additions to tolerations updates.
|
||||||
|
allErrs = append(allErrs, validateOnlyAddedTolerations(newPod.Spec.Tolerations, oldPod.Spec.Tolerations, specPath.Child("tolerations"))...)
|
||||||
|
|
||||||
// handle updateable fields by munging those fields prior to deep equal comparison.
|
// handle updateable fields by munging those fields prior to deep equal comparison.
|
||||||
mungedPod := *newPod
|
mungedPod := *newPod
|
||||||
// munge spec.containers[*].image
|
// munge spec.containers[*].image
|
||||||
@@ -4010,10 +4014,6 @@ func ValidatePodUpdate(newPod, oldPod *core.Pod, opts PodValidationOptions) fiel
|
|||||||
mungedPod.Spec.ActiveDeadlineSeconds = &activeDeadlineSeconds
|
mungedPod.Spec.ActiveDeadlineSeconds = &activeDeadlineSeconds
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow only additions to tolerations updates.
|
|
||||||
mungedPod.Spec.Tolerations = oldPod.Spec.Tolerations
|
|
||||||
allErrs = append(allErrs, validateOnlyAddedTolerations(newPod.Spec.Tolerations, oldPod.Spec.Tolerations, specPath.Child("tolerations"))...)
|
|
||||||
|
|
||||||
if !apiequality.Semantic.DeepEqual(mungedPod.Spec, oldPod.Spec) {
|
if !apiequality.Semantic.DeepEqual(mungedPod.Spec, oldPod.Spec) {
|
||||||
// This diff isn't perfect, but it's a helluva lot better an "I'm not going to tell you what the difference is".
|
// This diff isn't perfect, but it's a helluva lot better an "I'm not going to tell you what the difference is".
|
||||||
//TODO: Pinpoint the specific field that causes the invalid error after we have strategic merge diff
|
//TODO: Pinpoint the specific field that causes the invalid error after we have strategic merge diff
|
||||||
|
Reference in New Issue
Block a user