-
Notifications
You must be signed in to change notification settings - Fork 38.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
limitranger allow pod update #124887
base: master
Are you sure you want to change the base?
limitranger allow pod update #124887
Conversation
Hi @mouuii. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mouuii The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
84d2679
to
afb96b0
Compare
/sig node |
/cc tallclair |
/release-note-none Looks good overall. |
/cc |
I'm not familiar with writing e2e and I think this change will only affect performance ? |
should the changes done here be gated by the InPlaceVerticalAutoscaling featuregate, like we do e.g. in the kubelet? |
Good point. +1 |
// Since containers and initContainers cannot currently be added, removed, or updated, it is unnecessary | ||
// to mutate and validate limitrange on pod updates. Trying to mutate containers or initContainers on a pod | ||
// update request will always fail pod validation because those fields are immutable once the object is created. | ||
if a.GetKind().GroupKind() == api.Kind("Pod") && a.GetOperation() == admission.Update { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a.GetKind().GroupKind() == api.Kind("Pod") && a.GetOperation() == admission.Update && !utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) {
return false
}
Would it be better to still retain this part of the decision logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The part of the decision logic is to fix the bug mentioned in #62666 . Does the bug still exist ?
The featuregate condition added just make it more confused to others . Can we find a better way to fix ?
like modify here:
kubernetes/pkg/apis/core/validation/validation.go
Lines 5250 to 5260 in fd2d352
if !apiequality.Semantic.DeepEqual(mungedPodSpec, 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". | |
// TODO: Pinpoint the specific field that causes the invalid error after we have strategic merge diff | |
specDiff := cmp.Diff(oldPod.Spec, mungedPodSpec) | |
errs := field.Forbidden(specPath, fmt.Sprintf("pod updates may not change fields other than %s\n%v", strings.Join(updatablePodSpecFieldsNoResources, ","), specDiff)) | |
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) { | |
errs = field.Forbidden(specPath, fmt.Sprintf("pod updates may not change fields other than %s\n%v", strings.Join(updatablePodSpecFields, ","), specDiff)) | |
} | |
allErrs = append(allErrs, errs) | |
} | |
return allErrs |
BTW, unit test must modify to consider the featuregate into ,to be honest , hate the feature gate mechanism .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding a FeatureGate condition is to avoid unnecessary processing when the InPlacePodVerticalScaling feature is not enabled. As for whether the bug will recur, more test cases need to be written.
I find code below allow pod to update resource request and limit , but when old pod have not set resource it will return errors ,because of the Qos . kubernetes/pkg/apis/core/validation/validation.go Lines 5139 to 5154 in 03ad8e5
|
/triage accepted |
What type of PR is this?
/kind feature
What this PR does / why we need it:
The LimitRanger admission plugin does not currently handle pod updates, but needs to be updated to account for InPlacePodVerticalScaling:
Which issue(s) this PR fixes:
Fixes #124855
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: