Skip to content

[release-4.22] OCPBUGS-142037: UPSTREAM: 139522: kubelet: fix in-place pod resize with non-admitted pods - #2859

Open
haircommander wants to merge 1 commit into
openshift:release-4.22from
haircommander:OCPBUGS-64847-release-4.22
Open

haircommander wants to merge 1 commit into
openshift:release-4.22from
haircommander:OCPBUGS-64847-release-4.22

Conversation

@haircommander

@haircommander haircommander commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

/kind bug

What this PR does / why we need it:

Backports upstream kubernetes#139522 to release-4.22 (carry of UPSTREAM: 139522, same patch already merged to master via #2667 and shipped in 5.0/5.1).

When a pod is rejected at admission (OutOfcpu), it stays in GetActivePods() with no entry in the allocation checkpoint. getAllocatedPods() returned it unchanged, so its full spec request was summed into the "used" value for every subsequent admission on that node:

OutOfcpu: Node didn't have enough resource: cpu, requested: 40, used: 1000000000003188, capacity: 7500

The poisoner is test/e2e/node/pod_admission.go (PodRejectionStatus), which requests cpu: 1000000000000 and force-Binds the pod to the node to exercise the kubelet rejection path. 1e12 cores = 1e15 millicores, which is the 1000000000000000 in the message above (plus ~3188m of legitimately running pods). The next pod created on the node is rejected, which is how it shows up as a failure in unrelated tests, e.g. [sig-node] Pod InPlace Resize Container guaranteed qos - 1 container with resize policy cpu & mem restart resizing cpu & mem in the same direction:

https://prow.ci.openshift.org/view/gs/test-platform-results-public/logs/periodic-ci-openshift-release-main-ci-4.22-e2e-aws-upgrade-ovn-single-node/2120057983105765376

The fix folds two changes:

  • getAllocatedPods() only returns pods that actually have an allocation (HasPodAllocatedResources), so pods that are pending admission or were rejected do not count against node capacity.
  • HandlePodUpdates / HandlePodReconcile skip pods without an allocation, so a rejected pod is never handed to the pod workers and cannot be treated as actively terminating.

Backport notes: release-4.22 is based on Kubernetes v1.35, where PushPendingResize/AddPod/SetAllocatedResources do not take a logger/context yet, and HandlePodReconcile has no terminal-pod retry branch. The patch is otherwise 1:1 with the upstream commit, including its unit tests. The extra setAllocation: false case added to TestHandlePodReconcile_RetryPendingResizes covers the 1.35 equivalent of upstream's "allocation already purged" case: with no allocation the effective requests fall back to the spec, so no shrink is observed and no spurious retry is triggered.

Which issue(s) this PR is related to:

https://redhat.atlassian.net/browse/OCPBUGS-142037 (4.22 tracking bug)

https://redhat.atlassian.net/browse/OCPBUGS-64847 (5.0 variant, fixed via RHEA-2026:4893)

Upstream: kubernetes#139522

Special notes for your reviewer:

OCPBUGS-142037 blocks OCPBUGS-64847: the 5.0 bug is closed because the kubelet fix shipped there, while release-4.22 still carries the unfixed accounting.

Does this PR introduce a user-facing change?

Fixed a bug where pods rejected during admission (e.g. OutOfcpu) were still counted against node capacity, causing subsequent pods on the node to be rejected with an astronomically wrong "used" value.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


Testing

  • go build ./pkg/kubelet/...
  • go test ./pkg/kubelet/ (passes)
  • go test ./pkg/kubelet/allocation/... ./pkg/kubelet/status/... ./pkg/kubelet/lifecycle/... (passes)
  • New unit coverage: TestNonAllocatedPodsExcludedFromCapacity_AddPod reproduces the reported failure (a pending, never-allocated pod requesting 10 CPU must not block admission of a new pod) and fails without the getAllocatedPods() change.

AI was used to port this backport and to draft this description; the change was reviewed and tested as above and the author is responsible for the contents.

…pods

Exclude non-admitted pods from allocation capacity calculations.
Also skip non-allocated pods in HandlePodUpdates and HandlePodReconcile

Signed-off-by: Peter Hunt <pehunt@redhat.com>
@openshift-merge-bot

Copy link
Copy Markdown

Pipeline controller notification

This PR uses the pipeline controller for second-stage tests. Selection and triggering follow the repository configuration.

Use /test ? to list jobs and /pipeline help for commands.

@openshift-ci-robot openshift-ci-robot added backports/validated-commits Indicates that all commits come to merged upstream PRs. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. labels Nov 17, 2026
@openshift-ci openshift-ci Bot added the kind/bug Categorizes issue or PR as related to a bug. label Nov 17, 2026
@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Nov 17, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@haircommander: This pull request references Jira Issue OCPBUGS-64847, which is invalid:

  • expected the bug to be open, but it isn't
  • expected the bug to target either version "4.22.0." or "openshift-4.22.0.", but it targets "5.0.0" instead
  • expected the bug to be in one of the following states: NEW, ASSIGNED, POST, but it is Closed (Done) instead
  • expected Jira Issue OCPBUGS-64847 to depend on a bug targeting a version in 5.0.0, 5.0.z and in one of the following states: VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA), but no dependents were found

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

/kind bug

What this PR does / why we need it:

Backports upstream kubernetes#139522 to release-4.22 (carry of UPSTREAM: 139522, same patch already merged to master via #2667 and shipped in 5.0/5.1).

When a pod is rejected at admission (OutOfcpu), it stays in GetActivePods() with no entry in the allocation checkpoint. getAllocatedPods() returned it unchanged, so its full spec request was summed into the "used" value for every subsequent admission on that node:

OutOfcpu: Node didn't have enough resource: cpu, requested: 40, used: 1000000000003188, capacity: 7500

The poisoner is test/e2e/node/pod_admission.go (PodRejectionStatus), which requests cpu: 1000000000000 and force-Binds the pod to the node to exercise the kubelet rejection path. 1e12 cores = 1e15 millicores, which is the 1000000000000000 in the message above (plus ~3188m of legitimately running pods). The next pod created on the node is rejected, which is how it shows up as a failure in unrelated tests, e.g. [sig-node] Pod InPlace Resize Container guaranteed qos - 1 container with resize policy cpu & mem restart resizing cpu & mem in the same direction:

https://prow.ci.openshift.org/view/gs/test-platform-results-public/logs/periodic-ci-openshift-release-main-ci-4.22-e2e-aws-upgrade-ovn-single-node/2120057983105765376

The fix folds two changes:

  • getAllocatedPods() only returns pods that actually have an allocation (HasPodAllocatedResources), so pods that are pending admission or were rejected do not count against node capacity.
  • HandlePodUpdates / HandlePodReconcile skip pods without an allocation, so a rejected pod is never handed to the pod workers and cannot be treated as actively terminating.

Backport notes: release-4.22 is based on Kubernetes v1.35, where PushPendingResize/AddPod/SetAllocatedResources do not take a logger/context yet, and HandlePodReconcile has no terminal-pod retry branch. The patch is otherwise 1:1 with the upstream commit, including its unit tests. The extra setAllocation: false case added to TestHandlePodReconcile_RetryPendingResizes covers the 1.35 equivalent of upstream's "allocation already purged" case: with no allocation the effective requests fall back to the spec, so no shrink is observed and no spurious retry is triggered.

Which issue(s) this PR is related to:

https://redhat.atlassian.net/browse/OCPBUGS-64847

Upstream: kubernetes#139522

Special notes for your reviewer:

OCPBUGS-64847 is currently closed (fixed via RHEA-2026:4893 for a newer minor); this is the missing 4.22 fix for the same signature. Happy to re-point this at a cloned 4.22 tracking bug if that is preferred.

Does this PR introduce a user-facing change?

Fixed a bug where pods rejected during admission (e.g. OutOfcpu) were still counted against node capacity, causing subsequent pods on the node to be rejected with an astronomically wrong "used" value.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


Testing

  • go build ./pkg/kubelet/...
  • go test ./pkg/kubelet/ (passes)
  • go test ./pkg/kubelet/allocation/... ./pkg/kubelet/status/... ./pkg/kubelet/lifecycle/... (passes)
  • New unit coverage: TestNonAllocatedPodsExcludedFromCapacity_AddPod reproduces the reported failure (a pending, never-allocated pod requesting 10 CPU must not block admission of a new pod) and fails without the getAllocatedPods() change.

AI was used to port this backport and to draft this description; the change was reviewed and tested as above and the author is responsible for the contents.

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 openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Pre-merge checks: Passed 10

Check name Status Explanation
Stable And Deterministic Test Names Passed The check covers Ginkgo test titles (It, Describe, Context, When, DescribeTable, Entry). This PR is a kubelet backport of upstream #139522. Its new tests are plain Go unit tests in pkg/kubelet, not Gi…
Test Structure And Quality Passed The check is not applicable to this PR. It defines quality rules for Ginkgo test code (It blocks, BeforeEach/AfterEach, Eventually timeouts, Gomega assertion messages, and informing markers for new It…
Microshift Test Compatibility Passed The check applies only when the pull request adds new Ginkgo e2e tests (It/Describe/Context/When). This PR is a kubelet fix backport (openshift/kubernetes PR #2859, author haircommander, base release-…
Single Node Openshift (Sno) Test Compatibility Passed Summary: This check applies only when the PR adds new Ginkgo e2e tests (It, Describe, Context, When). The PR does not appear to add any. Evidence: - The PR is openshift/kubernetes #285…
Topology-Aware Scheduling Compatibility Passed The check is inapplicable to this pull request. Its scope is deployment manifests, operator code, and controllers that add or modify scheduling constraints (anti-affinity, topology spread, node select…
Ote Binary Stdout Contract Passed The OTE Binary Stdout Contract check covers only process-level stdout writes in OTE test binaries: main(), init(), TestMain(), suite setup, and top-level initializers. The PR changes kubelet runtime c…
Ipv6 And Disconnected Network Test Compatibility Passed The check applies only when the pull request adds new Ginkgo e2e tests (It, Describe, Context, When). PR #2859 (author haircommander, base release-4.22) changes four files against …
No-Weak-Crypto Passed no-weak-crypto: PASS. The PR changes kubelet pod-resource accounting, not cryptography. The PR description names these changed areas: getAllocatedPods(), HandlePodUpdates / `HandlePodReconcile…
Container-Privileges Passed The container-privileges check looks for privileged: true, hostPID, hostNetwork, hostIPC, SYS_ADMIN, root without justification, and allowPrivilegeEscalation: true in container or Kubernetes manifests…
No-Sensitive-Data-In-Logs Passed The PR adds two log statements, and neither exposes sensitive data. - pkg/kubelet/kubelet.go:2822 (in HandlePodUpdates): `klog.V(4).InfoS("Skipping pod update for non-allocated pod", "pod", klog.K…
Full details: Stable And Deterministic Test Names

Explanation

The check covers Ginkgo test titles (It, Describe, Context, When, DescribeTable, Entry). This PR is a kubelet backport of upstream #139522. Its new tests are plain Go unit tests in pkg/kubelet, not Ginkgo specs: - TestNonAllocatedPodsExcludedFromCapacity_Resize and TestNonAllocatedPodsExcludedFromCapacity_AddPod in pkg/kubelet/allocation/allocation_manager_test.go (lines 2483 and 2522). - A new setAllocation: false table case in TestHandlePodReconcile_RetryPendingResizes in pkg/kubelet/kubelet_test.go (line 4584). pkg/kubelet contains no Ginkgo imports. These Go function names are static strings with no pod names, timestamps, UUIDs, node names, or IP addresses, so they would pass the naming rules even if they were in scope. The PR description names test/e2e/node/pod_admission.go as the existing reproducer for the poisoning. Its title, "should reject pod when the node didn't have enough resource", is static and contains no dynamic values. The repository is a single root commit, so I could not confirm the full diff against the base. The description and the kubelet-scoped file evidence do not indicate any e2e Ginkgo title was added or changed. I found no Ginkgo title in the PR that violates the check. No legacy openshift-tests-private prefix tokens were found in the PR's test names.

Full details: Test Structure And Quality

Explanation

The check is not applicable to this PR. It defines quality rules for Ginkgo test code (It blocks, BeforeEach/AfterEach, Eventually timeouts, Gomega assertion messages, and informing markers for new It() blocks). Evidence: - The PR is a kubelet backport of upstream kubernetes#139522. Its description says the patch touches getAllocatedPods(), HandlePodUpdates, and HandlePodReconcile, plus unit tests. - The added or extended tests are plain Go testing functions, not Ginkgo specs: - TestNonAllocatedPodsExcludedFromCapacity_AddPod and TestNonAllocatedPodsExcludedFromCapacity_Resize in pkg/kubelet/allocation/allocation_manager_test.go (around lines 2481-2530). - TestHandlePodReconcile_RetryPendingResizes in pkg/kubelet/kubelet_test.go (line 4584). The PR adds a setAllocation: false case to it. - Neither file contains ginkgo, gomega, g.It(, or ote.Informing references. The grep found no matches in either file. - test/e2e/node/pod_admission.go is mentioned only as the reproduction source. The description does not say this PR changes it. Its Ginkgo It block ("should reject pod when the node didn't have enough resource") exists in the tree, but the PR description does not list it as changed. Limitation: the checkout is a single squashed commit with no parent, so the exact per-file PR diff cannot be isolated from git history. The verdict relies on the PR description and on the test function names and content found in the tree. No new Ginkgo It() block appears in the PR scope, so criterion 6 (informing markers) does not apply, and criteria 1-5 do not apply to plain Go unit tests.

Full details: Microshift Test Compatibility

Explanation

The check applies only when the pull request adds new Ginkgo e2e tests (It/Describe/Context/When). This PR is a kubelet fix backport (openshift/kubernetes PR #2859, author haircommander, base release-4.22). Its changes, as described in the PR, are in pkg/kubelet: getAllocatedPods() filtering via HasPodAllocatedResources, and HandlePodUpdates/HandlePodReconcile skipping pods without an allocation. The new tests are standard Go unit tests: TestNonAllocatedPodsExcludedFromCapacity_AddPod in pkg/kubelet/allocation/allocation_manager_test.go and an extra case in TestHandlePodReconcile_RetryPendingResizes in pkg/kubelet/kubelet_test.go. Both tests exist in the checkout. No g.It/ginkgo.It usage appears in pkg/kubelet/allocation, status, or lifecycle. The PR description names test/e2e/node/pod_admission.go only as the pre-existing test that triggers the bug. It does not say that file was modified. Limitation: the local checkout is a single root commit with no parent, so a base-relative diff could not be computed. The conclusion relies on the PR description and on the content of the named test files. No new Ginkgo e2e test is identified, so no MicroShift compatibility concern is raised.

Full details: Single Node Openshift (Sno) Test Compatibility

Explanation

Summary: This check applies only when the PR adds new Ginkgo e2e tests (It, Describe, Context, When). The PR does not appear to add any. Evidence: - The PR is openshift/kubernetes #2859 (author login haircommander, base release-4.22). It backports upstream kubernetes#139522, a kubelet in-place resize fix. - The PR description lists the changes as getAllocatedPods() filtering on HasPodAllocatedResources, plus HandlePodUpdates/HandlePodReconcile skipping pods without an allocation. It also lists the new unit test TestNonAllocatedPodsExcludedFromCapacity_AddPod and an extra setAllocation: false case in TestHandlePodReconcile_RetryPendingResizes. These are Go testing unit tests in pkg/kubelet, not Ginkgo specs. - test/e2e/node/pod_admission.go is cited only as the existing test that triggers the bug. The PR does not add or change it. - I searched the added lines of the carry commit for Ginkgo constructs (g.It(, g.Describe(, g.Context(, g.When(, ginkgo.It(, framework.ConformanceIt). The only matches were unrelated code such as request.Context(), RateLimiter.When(), and existing [Skipped:...] label helpers in shared framework code. None were new e2e specs. Limitation: The checkout's HEAD commit is a full-tree snapshot with no usable parent. I could not isolate the exact PR diff from git, so this verdict rests on the PR description and the kubelet-scoped file list. Any new Ginkgo spec added outside that description would change the result. Conclusion: No new Ginkgo e2e tests are introduced, so the SNO topology criteria do not apply. The check passes.

Full details: Topology-Aware Scheduling Compatibility

Explanation

The check is inapplicable to this pull request. Its scope is deployment manifests, operator code, and controllers that add or modify scheduling constraints (anti-affinity, topology spread, node selectors, tolerations, PDBs, replica counts). PR #2859 (target release-4.22, author haircommander) is a backport of upstream kubernetes#139522. It changes kubelet pod-admission accounting. The changed logic is in pkg/kubelet/allocation/allocation_manager.go: getAllocatedPods() now keeps only pods where HasPodAllocatedResources is true. HandlePodUpdates and HandlePodReconcile skip pods without an allocation. The PR also adds unit tests. The PR description cites test/e2e/node/pod_admission.go, which exercises kubelet rejection. None of this adds or changes a deployment manifest, operator, controller, or scheduling constraint. The kubelet capacity check is not a scheduling constraint in the check's sense. Limitation: the sandbox checkout is a single squashed commit with no parent, so I could not produce a full file-level diff. I confirmed the allocation-manager code and the PR description, and I found no manifest or operator changes in the PR description.

Full details: Ote Binary Stdout Contract

Explanation

The OTE Binary Stdout Contract check covers only process-level stdout writes in OTE test binaries: main(), init(), TestMain(), suite setup, and top-level initializers. The PR changes kubelet runtime code. Per the PR description and the local tree, the changes sit in pkg/kubelet: getAllocatedPods() in kubelet_pods.go and allocation_manager.go, HandlePodUpdates/HandlePodReconcile, and the unit tests TestNonAllocatedPodsExcludedFromCapacity_AddPod and TestHandlePodReconcile_RetryPendingResizes. The description names test/e2e/node/pod_admission.go only as the existing test that triggers the bug. It does not say that file changed. A search of the kubelet files involved (pkg/kubelet/allocation, kubelet_pods.go, kubelet.go, pod_workers.go) found no fmt.Print*, os.Stdout, klog.SetOutput, or LogToStderr uses. The checkout is a single squashed commit with no parent, so I could not produce a per-file diff. That limits certainty about the exact file list. Nothing in the described scope falls under the check's process-level criteria, so the check is inapplicable.

Full details: Ipv6 And Disconnected Network Test Compatibility

Explanation

The check applies only when the pull request adds new Ginkgo e2e tests (It, Describe, Context, When). PR #2859 (author haircommander, base release-4.22) changes four files against its parent commit e2a920b: pkg/kubelet/allocation/allocation_manager.go, pkg/kubelet/allocation/allocation_manager_test.go, pkg/kubelet/kubelet.go, and pkg/kubelet/kubelet_test.go. No file under test/ changes, and a diff search for added It(, Describe(, Context(, or When( blocks found none. The new test, TestNonAllocatedPodsExcludedFromCapacity_AddPod, is a Go unit test in pkg/kubelet/allocation and not a Ginkgo e2e test. The existing PodRejectionStatus e2e test in test/e2e/node/pod_admission.go is unchanged and is only referenced in the PR description. Because no new e2e test is added, the IPv4 and external-connectivity criteria do not apply.

Full details: No-Weak-Crypto

Explanation

no-weak-crypto: PASS. The PR changes kubelet pod-resource accounting, not cryptography. The PR description names these changed areas: getAllocatedPods(), HandlePodUpdates / HandlePodReconcile, PushPendingResize / AddPod / SetAllocatedResources, and test/e2e/node/pod_admission.go. Evidence gathered: - The local checkout holds a single root commit (3c2bec97, no parent). Its full tree is therefore present, and a base-to-head diff could not be isolated. I did not treat the whole tree as PR-introduced. - Scanning the added lines of the commit for weak-crypto patterns returned only generic TLS and certificate code from the vendored API types and generated files, such as TLSCipherSuites, crypto/x509, and crypto/tls. None of these lines is a weak primitive or a weak mode. - The files named in the PR description (allocation_manager.go and its test, kubelet.go, kubelet_pods.go, pod_workers.go, status_manager.go, lifecycle/predicate.go, test/e2e/node/pod_admission.go) contain no MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB, or custom cipher usage. - A repo-wide import scan of pkg/kubelet and test/e2e/node found no imports of crypto/md5, crypto/sha1, crypto/des, crypto/rc4, or golang.org/x/crypto/blowfish. - The only bytes.Equal hit in the scanned files is in pkg/kubelet/allocation code that compares pod-resource data, not a secret or token. No secret or token comparison appears in the PR's changed areas. Limitation: the PR patch was not isolated as a diff. The PASS rests on the PR description's scope and on the scan of the named and kubelet files. The check does not define a failure for a missing diff.

Full details: Container-Privileges

Explanation

The container-privileges check looks for privileged: true, hostPID, hostNetwork, hostIPC, SYS_ADMIN, root without justification, and allowPrivilegeEscalation: true in container or Kubernetes manifests. Evidence gathered: - The PR is openshift/kubernetes #2859 by haircommander, targeting release-4.22. The contributor describes it as a kubelet backport of upstream #139522. It changes pod admission accounting in getAllocatedPods() and skips pods without an allocation in HandlePodUpdates/HandlePodReconcile. It also adds unit tests. - The checked-out HEAD is a single root commit with no parent. Git cannot isolate the PR delta from a base, so the full patch could not be diffed directly. - Within the commit's kubelet and e2e Go paths, I found no added container manifest or security setting tied to this change. The HasPodAllocatedResources and getAllocatedPods logic is present in pkg/kubelet/allocation/allocation_manager.go. - test/e2e/node/pod_admission.go (the PodRejectionStatus test named in the description) sets no Privileged, host*, SYS_ADMIN, or allowPrivilegeEscalation field. It only requests CPU and expects OutOfcpu. - Grep hits for Privileged or HostNetwork in the commit come from unrelated pre-existing test code and vendored or generated files. They are not part of the described PR changes. - No YAML or JSON manifest in the PR scope is described as adding privileged, host namespace, or capability settings. The PR does not introduce any condition the check lists. Limitation: the root-commit snapshot prevents a strict file-by-file diff confirmation, so this rests on the PR description and the targeted code inspection.

Full details: No-Sensitive-Data-In-Logs

Explanation

The PR adds two log statements, and neither exposes sensitive data. - pkg/kubelet/kubelet.go:2822 (in HandlePodUpdates): klog.V(4).InfoS("Skipping pod update for non-allocated pod", "pod", klog.KObj(pod), "podUID", pod.UID). - pkg/kubelet/kubelet.go:3050 (in HandlePodReconcile): klog.V(4).InfoS("Skipping pod reconcile operations for non-allocated pod", "pod", klog.KObj(pod), "podUID", pod.UID). Both log only the namespace/name reference and the pod UID. They log no passwords, tokens, API keys, PII, session IDs, hostnames, or customer payload data. The other log calls in the touched files predate this change, and none of them is new in this diff. The changes to getAllocatedPods() and the test files add no logging. Limitation: the checkout is a single squashed commit with no parent, so I identified the added lines by reading the changed functions. I did not run a line-level diff. The grep over the touched kubelet files found no other sensitive-data keywords in log calls.

@openshift-ci-robot

Copy link
Copy Markdown

@haircommander: the contents of this pull request could be automatically validated.

The following commits are valid:

Comment /validate-backports to re-evaluate validity of the upstream PRs, for example when they are merged upstream.

@openshift-ci
openshift-ci Bot requested review from rphillips and sjenning November 17, 2026 20:59
@openshift-ci

openshift-ci Bot commented Nov 17, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mrunalp 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

@haircommander haircommander changed the title [release-4.22] OCPBUGS-64847: UPSTREAM: 139522: kubelet: fix in-place pod resize with non-admitted pods [release-4.22] OCPBUGS-142037: UPSTREAM: 139522: kubelet: fix in-place pod resize with non-admitted pods Nov 17, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@haircommander: This pull request references Jira Issue OCPBUGS-142037, which is invalid:

  • release note text must be set and not match the template OR release note type must be set to "Release Note Not Required". For more information you can reference the OpenShift Bug Process.
  • expected Jira Issue OCPBUGS-142037 to depend on a bug targeting a version in 5.0.0, 5.0.z and in one of the following states: VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA), but no dependents were found

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

/kind bug

What this PR does / why we need it:

Backports upstream kubernetes#139522 to release-4.22 (carry of UPSTREAM: 139522, same patch already merged to master via #2667 and shipped in 5.0/5.1).

When a pod is rejected at admission (OutOfcpu), it stays in GetActivePods() with no entry in the allocation checkpoint. getAllocatedPods() returned it unchanged, so its full spec request was summed into the "used" value for every subsequent admission on that node:

OutOfcpu: Node didn't have enough resource: cpu, requested: 40, used: 1000000000003188, capacity: 7500

The poisoner is test/e2e/node/pod_admission.go (PodRejectionStatus), which requests cpu: 1000000000000 and force-Binds the pod to the node to exercise the kubelet rejection path. 1e12 cores = 1e15 millicores, which is the 1000000000000000 in the message above (plus ~3188m of legitimately running pods). The next pod created on the node is rejected, which is how it shows up as a failure in unrelated tests, e.g. [sig-node] Pod InPlace Resize Container guaranteed qos - 1 container with resize policy cpu & mem restart resizing cpu & mem in the same direction:

https://prow.ci.openshift.org/view/gs/test-platform-results-public/logs/periodic-ci-openshift-release-main-ci-4.22-e2e-aws-upgrade-ovn-single-node/2120057983105765376

The fix folds two changes:

  • getAllocatedPods() only returns pods that actually have an allocation (HasPodAllocatedResources), so pods that are pending admission or were rejected do not count against node capacity.
  • HandlePodUpdates / HandlePodReconcile skip pods without an allocation, so a rejected pod is never handed to the pod workers and cannot be treated as actively terminating.

Backport notes: release-4.22 is based on Kubernetes v1.35, where PushPendingResize/AddPod/SetAllocatedResources do not take a logger/context yet, and HandlePodReconcile has no terminal-pod retry branch. The patch is otherwise 1:1 with the upstream commit, including its unit tests. The extra setAllocation: false case added to TestHandlePodReconcile_RetryPendingResizes covers the 1.35 equivalent of upstream's "allocation already purged" case: with no allocation the effective requests fall back to the spec, so no shrink is observed and no spurious retry is triggered.

Which issue(s) this PR is related to:

https://redhat.atlassian.net/browse/OCPBUGS-142037 (4.22 tracking bug)

https://redhat.atlassian.net/browse/OCPBUGS-64847 (5.0 variant, fixed via RHEA-2026:4893)

Upstream: kubernetes#139522

Special notes for your reviewer:

OCPBUGS-142037 blocks OCPBUGS-64847: the 5.0 bug is closed because the kubelet fix shipped there, while release-4.22 still carries the unfixed accounting.

Does this PR introduce a user-facing change?

Fixed a bug where pods rejected during admission (e.g. OutOfcpu) were still counted against node capacity, causing subsequent pods on the node to be rejected with an astronomically wrong "used" value.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


Testing

  • go build ./pkg/kubelet/...
  • go test ./pkg/kubelet/ (passes)
  • go test ./pkg/kubelet/allocation/... ./pkg/kubelet/status/... ./pkg/kubelet/lifecycle/... (passes)
  • New unit coverage: TestNonAllocatedPodsExcludedFromCapacity_AddPod reproduces the reported failure (a pending, never-allocated pod requesting 10 CPU must not block admission of a new pod) and fails without the getAllocatedPods() change.

AI was used to port this backport and to draft this description; the change was reviewed and tested as above and the author is responsible for the contents.

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 openshift-eng/jira-lifecycle-plugin repository.

@haircommander

Copy link
Copy Markdown
Member Author

/jira refresh

@openshift-ci-robot

Copy link
Copy Markdown

@haircommander: This pull request references Jira Issue OCPBUGS-142037, which is invalid:

  • release note text must be set and not match the template OR release note type must be set to "Release Note Not Required". For more information you can reference the OpenShift Bug Process.
  • expected Jira Issue OCPBUGS-142037 to depend on a bug targeting a version in 5.0.0, 5.0.z and in one of the following states: VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA), but no dependents were found

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

Details

In response to this:

/jira refresh

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 openshift-eng/jira-lifecycle-plugin repository.

@haircommander

Copy link
Copy Markdown
Member Author

/jira refresh

@openshift-ci-robot

Copy link
Copy Markdown

@haircommander: This pull request references Jira Issue OCPBUGS-142037, which is invalid:

  • expected Jira Issue OCPBUGS-142037 to depend on a bug targeting a version in 5.0.0, 5.0.z and in one of the following states: VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA), but no dependents were found

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

Details

In response to this:

/jira refresh

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 openshift-eng/jira-lifecycle-plugin repository.

@haircommander

Copy link
Copy Markdown
Member Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Nov 17, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@haircommander: This pull request references Jira Issue OCPBUGS-142037, which is valid. The bug has been moved to the POST state.

7 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)
  • release note text is set and does not match the template
  • dependent bug Jira Issue OCPBUGS-64847 is in the state Closed (Done), which is one of the valid states (VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA))
  • dependent Jira Issue OCPBUGS-64847 targets the "5.0.0" version, which is one of the valid target versions: 5.0.0, 5.0.z
  • bug has dependents
Details

In response to this:

/jira refresh

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 openshift-eng/jira-lifecycle-plugin repository.

@haircommander

Copy link
Copy Markdown
Member Author

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown

Scheduling required tests:
/test configmap-scale
/test e2e-aws-ovn-cgroupsv2
/test e2e-aws-ovn-crun
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp
/test e2e-metal-ipi-ovn-ipv6
/test k8s-e2e-conformance-aws
/test k8s-e2e-gcp-ovn
/test k8s-e2e-gcp-serial
/test perfscale-control-plane-6nodes

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-ovn-hypershift

@openshift-ci

openshift-ci Bot commented Nov 18, 2026

Copy link
Copy Markdown

@haircommander: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-ovn-crun 3c2bec9 link true /test e2e-aws-ovn-crun
ci/prow/e2e-gcp 3c2bec9 link true /test e2e-gcp
ci/prow/e2e-metal-ipi-ovn-ipv6 3c2bec9 link true /test e2e-metal-ipi-ovn-ipv6

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

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

Labels

backports/validated-commits Indicates that all commits come to merged upstream PRs. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. kind/bug Categorizes issue or PR as related to a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants