Skip to content

OCPBUGS-64847: kubelet: don't use non-admitted pods in calculation#2667

Open
haircommander wants to merge 1 commit into
openshift:masterfrom
haircommander:fix-rejected-pod-3-openshift
Open

OCPBUGS-64847: kubelet: don't use non-admitted pods in calculation#2667
haircommander wants to merge 1 commit into
openshift:masterfrom
haircommander:fix-rejected-pod-3-openshift

Conversation

@haircommander
Copy link
Copy Markdown
Member

@haircommander haircommander commented May 13, 2026

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR is related to:

Special notes for your reviewer:

Does this PR introduce a user-facing change?


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


Summary by CodeRabbit

  • Refactor

    • Resource-allocation processing now updates only pods with stored allocation data or running legacy pods, reducing unnecessary updates and improving efficiency.
  • Tests

    • Added a test ensuring pending pods without allocations are excluded from capacity calculations during in-place resize retries.

@openshift-ci-robot openshift-ci-robot added the backports/unvalidated-commits Indicates that not all commits come to merged upstream PRs. label May 13, 2026
@openshift-ci-robot
Copy link
Copy Markdown

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

The following commits could not be validated and must be approved by a top-level approver:

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 mrunalp and sjenning May 13, 2026 20:20
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 13, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: haircommander
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
Copy link
Copy Markdown
Member Author

/payload-aggregate periodic-ci-openshift-hypershift-release-4.22-periodics-e2e-aws-ovn-conformance 10

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Walkthrough

Adds manager.hasPodAllocatedResources to query the allocation checkpoint store, and updates getAllocatedPods to include and call UpdatePodFromAllocation only for pods that either have allocated resources or are in Running phase; unit test verifies pending non-allocated pods are excluded from capacity calculations.

Changes

Pod allocation state filtering

Layer / File(s) Summary
Checkpoint presence helper
pkg/kubelet/allocation/allocation_manager.go
Adds manager.hasPodAllocatedResources(pod *v1.Pod) bool which queries the checkpoint state store for an allocated-resource entry for the given pod.
Allocated-pod selection and update flow
pkg/kubelet/allocation/allocation_manager.go
Reworks getAllocatedPods to iterate activePods but only call UpdatePodFromAllocation and append to the result when the pod is Running or hasPodAllocatedResources(pod) returns true; avoids updating/returning entries for pods without stored allocations.
Unit test validating exclusion of pending/unallocated pods
pkg/kubelet/allocation/allocation_manager_test.go
Adds TestPendingNonAllocatedPodsExcludedFromCapacity which configures a running (allocated) pod and a pending (unallocated) pod, triggers pending-resize retry, and asserts only the running pod participates in resize/capacity (no allocation created for pending pod).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed All tests use standard Go testing with static names. No Ginkgo BDD style tests found. All test identifiers are static strings with no dynamic information.
Test Structure And Quality ✅ Passed The custom check requires reviewing "Ginkgo test code," but the test file uses standard Go testing (testing.T) with testify, not Ginkgo. Check not applicable to this context.
Microshift Test Compatibility ✅ Passed PR adds only standard Go unit tests (testing.T), not Ginkgo e2e tests. Custom check for Ginkgo e2e test compatibility is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No Ginkgo e2e tests are added in this PR. The changes are limited to kubelet allocation manager internal code and unit tests (standard Go testing package, not Ginkgo). The check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies internal kubelet allocation logic with no deployment manifests, operator code, or scheduling constraints. No topology-aware scheduling issues detected.
Ote Binary Stdout Contract ✅ Passed PR modifies kubelet allocation logic with regular Go unit tests, not OTE test binaries. No process-level stdout writes found. Check not applicable.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR adds unit tests, not Ginkgo e2e tests. The custom check targets Ginkgo e2e tests specifically, so it does not apply to this pull request.
Title check ✅ Passed The title clearly identifies the main change: preventing non-admitted pods from being used in kubelet capacity calculations, which directly aligns with the code changes that filter pods based on allocation state.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 13, 2026

@haircommander: An error was encountered. No known errors were detected, please see the full error message for details.

Full error message. could not create PullRequestPayloadQualificationRun: rpc error: code = DeadlineExceeded desc = context deadline exceeded

Please contact an administrator to resolve this issue.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/kubelet/allocation/allocation_manager.go`:
- Around line 763-770: The allocatedPods slice is created with length
len(activePods) causing leading nil entries; change its allocation in
allocation_manager.go to use zero length and capacity len(activePods) (e.g.,
make([]*v1.Pod, 0, len(activePods))) so that appending allocatedPod from
m.UpdatePodFromAllocation(pod) produces a compact slice without nils; ensure the
loop using m.hasPodAllocatedResources and calling UpdatePodFromAllocation
continues to append to allocatedPods so callers like canAdmitPod can safely
access p.UID.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 06c6f732-792e-49ce-a11f-7e67b57d2902

📥 Commits

Reviewing files that changed from the base of the PR and between f9b62a6 and dad1533.

📒 Files selected for processing (1)
  • pkg/kubelet/allocation/allocation_manager.go

Comment thread pkg/kubelet/allocation/allocation_manager.go Outdated
@haircommander haircommander force-pushed the fix-rejected-pod-3-openshift branch from dad1533 to 921b35e Compare May 13, 2026 20:31
@openshift-ci-robot
Copy link
Copy Markdown

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

The following commits could not be validated and must be approved by a top-level approver:

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

@haircommander
Copy link
Copy Markdown
Member Author

/payload-aggregate periodic-ci-openshift-hypershift-release-4.22-periodics-e2e-aws-ovn-conformance 10

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 13, 2026

@haircommander: trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command

  • periodic-ci-openshift-hypershift-release-4.22-periodics-e2e-aws-ovn-conformance

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/38bcb890-4f0c-11f1-8489-0586b273e428-0

instead, check whether the pod is allocated, and return that when we return allocated pods

Signed-off-by: Peter Hunt <pehunt@redhat.com>
@haircommander haircommander force-pushed the fix-rejected-pod-3-openshift branch from 921b35e to 3cb4618 Compare May 14, 2026 15:58
@openshift-ci-robot
Copy link
Copy Markdown

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

The following commits could not be validated and must be approved by a top-level approver:

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

@haircommander
Copy link
Copy Markdown
Member Author

/payload-aggregate periodic-ci-openshift-hypershift-release-4.22-periodics-e2e-aws-ovn-conformance 10

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 14, 2026

@haircommander: trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command

  • periodic-ci-openshift-hypershift-release-4.22-periodics-e2e-aws-ovn-conformance

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/a43c4e10-4fb0-11f1-9de7-4de01fd38918-0

@haircommander
Copy link
Copy Markdown
Member Author

/retitle OCPBUGS-64847: kubelet: don't use non-admitted pods in calculation

@openshift-ci openshift-ci Bot changed the title kubelet: don't use non-admitted pods in calculation OCPBUGS-64847: kubelet: don't use non-admitted pods in calculation May 14, 2026
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels May 14, 2026
@openshift-ci-robot
Copy link
Copy Markdown

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

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (bgudi@redhat.com), skipping review request.

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

Details

In response to this:

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR is related to:

Special notes for your reviewer:

Does this PR introduce a user-facing change?


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


Summary by CodeRabbit

  • Refactor

  • Resource-allocation processing now updates only pods with stored allocation data or running legacy pods, reducing unnecessary updates and improving efficiency.

  • Tests

  • Added a test ensuring pending pods without allocations are excluded from capacity calculations during in-place resize retries.

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

/test k8s-e2e-conformance-aws

@haircommander
Copy link
Copy Markdown
Member Author

unit test and some debugging assisted by claude 4.5

@haircommander
Copy link
Copy Markdown
Member Author

/retest

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 14, 2026

@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-serial-2of2 3cb4618 link true /test e2e-aws-ovn-serial-2of2
ci/prow/e2e-aws-ovn-techpreview 3cb4618 link false /test e2e-aws-ovn-techpreview
ci/prow/e2e-gcp 3cb4618 link true /test e2e-gcp
ci/prow/e2e-aws-ovn-cgroupsv2 3cb4618 link true /test e2e-aws-ovn-cgroupsv2
ci/prow/e2e-aws-ovn-runc 3cb4618 link false /test e2e-aws-ovn-runc
ci/prow/e2e-aws-ovn-techpreview-serial-2of2 3cb4618 link false /test e2e-aws-ovn-techpreview-serial-2of2
ci/prow/verify-commits 3cb4618 link true /test verify-commits

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/unvalidated-commits Indicates that not 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants