Skip to content

Allow in-place pod resize to clear pod limits#138187

Open
abishekgiri wants to merge 1 commit into
kubernetes:masterfrom
abishekgiri:fix-kubelet-pod-resource-limit-removal
Open

Allow in-place pod resize to clear pod limits#138187
abishekgiri wants to merge 1 commit into
kubernetes:masterfrom
abishekgiri:fix-kubelet-pod-resource-limit-removal

Conversation

@abishekgiri
Copy link
Copy Markdown

@abishekgiri abishekgiri commented Apr 2, 2026

/kind bug

Summary

In-place pod resize could add or change pod-level CPU and memory limits, but it could not remove them.

If the desired pod-level limit was unset, kubelet fell back to the current cgroup value, so the old limit stayed in place. The actuated pod-level resource state could also keep the old limit when the updated pod spec no longer had that key.

This keeps a real "clear the limit" path through pod resize, uses the expected no-limit form when talking to cgroups and CRI, and updates the actuated pod-level state when a limit is removed.

Testing

  • go test ./pkg/kubelet/kuberuntime -run 'TestConvertResourceConfigToLinuxContainerResources|TestDoPodResizeAction|TestValidatePodResizeAction'
  • GOOS=linux GOARCH=amd64 go test -c -o /tmp/kuberuntime-linux.test ./pkg/kubelet/kuberuntime

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 2, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

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.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Apr 2, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @abishekgiri. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 2, 2026
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Apr 2, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: abishekgiri
Once this PR has been reviewed and has the lgtm label, please assign sjenning for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@abishekgiri
Copy link
Copy Markdown
Author

This fixes kubelet's in-place pod resize path so pod-level CPU and memory limits can actually be removed.

What changed:

  • unset desired pod-level limits are no longer defaulted back to the current cgroup values
  • pod cgroup writes now use the no-limit sentinel while runtime updates keep CRI's no-limit form
  • memory resize validation now treats an unlimited current pod limit as an unlimited baseline
  • the actuated pod-level resource record is updated even when the new pod spec omits the limit key
  • tests now cover clearing pod-level CPU and memory limits

Result:

  • removing a pod-level CPU or memory limit no longer leaves the old limit stuck in place
  • kubelet's actuated pod-level state stays in sync with the updated pod spec after a limit is cleared

Verification:

  • go test ./pkg/kubelet/kuberuntime -run 'TestConvertResourceConfigToLinuxContainerResources|TestDoPodResizeAction|TestValidatePodResizeAction'
  • GOOS=linux GOARCH=amd64 go test -c -o /tmp/kuberuntime-linux.test ./pkg/kubelet/kuberuntime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Development

Successfully merging this pull request may close these issues.

2 participants