Skip to content

Wrap pending workloads bucket operations in helpers to keep scheduling hashes in sync - #14889

Merged
kubernetes-prow[bot] merged 1 commit into
kubernetes-sigs:mainfrom
kavix:issue-14877
Sep 2, 2026
Merged

kubernetes-prow[bot] merged 1 commit into
kubernetes-sigs:mainfrom
kavix:issue-14877

Conversation

@kavix

@kavix kavix commented Aug 29, 2026 •

Copy link
Copy Markdown
Member

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

The queue layer keeps pending workloads in three buckets (active, inadmissible, inflight), plus a mirror that counts their scheduling hashes for the pending_scheduling_hashes metric. Previously, whenever a workload moved between buckets or was added/removed/updated, the bucket and the mirror were updated as two separate calls across pkg/cache/queue/pending_workloads.go.

This PR encapsulates each bucket mutation together with its scheduling equivalence hashes mirror update inside dedicated helper methods on PendingWorkloads (addActive, updateActive, deleteActive, addInadmissible, updateInadmissible, deleteInadmissible, moveInadmissibleToActive, moveActiveToInadmissible, setInflight, clearInflight). This ensures that the buckets and mirror cannot be changed independently, preventing the metric from drifting out of sync.

AI Disclosure: Assisted by Antigravity.

Which issue(s) this PR fixes:

Fixes #14877

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Summary by CodeRabbit

  • Refactor
    • Reorganized workload queue bookkeeping and scheduling operations.
    • Preserved existing behavior and functionality.

… sync

Encapsulate pending workloads bucket modifications (active, inadmissible, inflight) along with their scheduling equivalence hashes updates in helper methods. This prevents the scheduling equivalence hashes mirror from drifting out of sync with the buckets.

Signed-off-by: Kavindu Sachinthe <kavix@yahoo.com>
@kubernetes-prow kubernetes-prow Bot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Aug 29, 2026
@netlify

netlify Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kubernetes-sigs-kueue ready!

Name Link
🔨 Latest commit b286e94
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-kueue/deploys/6a929a2486908000074e4a42
😎 Deploy Preview https://deploy-preview-14889--kubernetes-sigs-kueue.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 29, 2026
@kubernetes-prow

Copy link
Copy Markdown

Hi @kavix. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

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.

@kubernetes-prow kubernetes-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 29, 2026
@coderabbitai

coderabbitai Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f833a59d-a4c3-469b-9339-b7d4d1506dc6

📥 Commits

Reviewing files that changed from the base of the PR and between 6123e3f and b286e94.

📒 Files selected for processing (1)
  • pkg/cache/queue/pending_workloads.go

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

PendingWorkloads now centralizes paired bucket and scheduling-hash updates in unexported helpers. Existing active, inadmissible, and inflight operations delegate to these helpers without changing behavior.

Changes

Pending workload queue

Layer / File(s) Summary
Paired update helpers
pkg/cache/queue/pending_workloads.go
Adds helpers that combine queue bucket mutations with corresponding scheduling-hash updates.
Queue operation delegation
pkg/cache/queue/pending_workloads.go
Updates active, inadmissible, inflight, and bucket-transition operations to use the shared helpers. Existing ordering and return behavior remain unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to b286e

This change centralizes pending-workload bucket updates with scheduling-hash metric updates; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #14877 by consolidating active, inadmissible, and inflight bucket mutations with their scheduling-hash mirror updates in helper methods.
Out of Scope Changes check ✅ Passed The changes are limited to the requested refactor in pkg/cache/queue/pending_workloads.go. They introduce no unrelated behavior or user-facing changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main refactor: it adds helper methods that keep pending-workload bucket operations and scheduling hashes synchronized.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

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

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

@mszadkow

mszadkow commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Everything looks fine
/lgtm

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 2, 2026
@kubernetes-prow

Copy link
Copy Markdown

LGTM label has been added.

DetailsGit tree hash: 8df9cd7f680e5b8d61e9d36755b6c45dda82cdcc

@kavix

kavix commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

/test all

@mimowo

mimowo commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

/ok-to-test

@kubernetes-prow kubernetes-prow Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 2, 2026

@mimowo mimowo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/approve
Thank you for this nice cleanup 👍 It is non trivial so I skip CP for now, but I think we can consider it if needed for other PRs

@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kavix, mimowo

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

The pull request process is described 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

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 2, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit 48f74e2 into kubernetes-sigs:main Sep 2, 2026
61 checks passed
@kubernetes-prow kubernetes-prow Bot added this to the v0.20 milestone Sep 2, 2026
@mimowo

mimowo commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

/lgtm

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate paired bucket + scheduling-hash updates in the queue layer

4 participants