Unverified Commit 164890ba authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #60683 from nilebox/pod-template-validation-fix

Automatic merge from submit-queue (batch tested with PRs 60683, 60386). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix PodTemplate validation **What this PR does / why we need it**: This is a bugfix for pod template validation, which can be reproduced by deleting with "foreground deletion" mode (`DeleteOptions.PropagationPolicy = metav1.DeletePropagationForeground`). Because of this bug GC will never delete a pod template with `foregroundDeletion` finalizer. **Special notes for your reviewer**: The issue was originally found and confirmed in the PR #59851, where switching to foreground deletion in `kubectl` broke a unit test revealing this bug. Extracted for easier backporting to releases as suggested in https://github.com/kubernetes/kubernetes/pull/59851#discussion_r171576397 /cc @liggitt @caesarxuchao /sig api-machinery ```release-note NONE ```
parents f9f5677b 0d36ab2f
...@@ -3503,7 +3503,7 @@ func ValidatePodTemplate(pod *core.PodTemplate) field.ErrorList { ...@@ -3503,7 +3503,7 @@ func ValidatePodTemplate(pod *core.PodTemplate) field.ErrorList {
// ValidatePodTemplateUpdate tests to see if the update is legal for an end user to make. newPod is updated with fields // ValidatePodTemplateUpdate tests to see if the update is legal for an end user to make. newPod is updated with fields
// that cannot be changed. // that cannot be changed.
func ValidatePodTemplateUpdate(newPod, oldPod *core.PodTemplate) field.ErrorList { func ValidatePodTemplateUpdate(newPod, oldPod *core.PodTemplate) field.ErrorList {
allErrs := ValidateObjectMetaUpdate(&oldPod.ObjectMeta, &newPod.ObjectMeta, field.NewPath("metadata")) allErrs := ValidateObjectMetaUpdate(&newPod.ObjectMeta, &oldPod.ObjectMeta, field.NewPath("metadata"))
allErrs = append(allErrs, ValidatePodTemplateSpec(&newPod.Template, field.NewPath("template"))...) allErrs = append(allErrs, ValidatePodTemplateSpec(&newPod.Template, field.NewPath("template"))...)
return allErrs return allErrs
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment