fix(proportion): avoid double-counting inqueue resources for jobs wit…#5100
fix(proportion): avoid double-counting inqueue resources for jobs wit…#5100Aman-Cool wants to merge 1 commit intovolcano-sh:masterfrom
Conversation
821fd32 to
cb329d5
Compare
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug in the proportion plugin that caused job scheduling issues due to incorrect resource accounting. Previously, jobs with tasks in a Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
cb329d5 to
aacb836
Compare
There was a problem hiding this comment.
Code Review
This pull request provides a solid fix for a double-counting bug within the proportion plugin, which could incorrectly inflate queue resource usage and block schedulable jobs. The change correctly calculates in-queue resources by subtracting already allocated resources for jobs in the Binding state, aligning the logic with how Running jobs are handled. The addition of a comprehensive regression test is excellent, as it clearly demonstrates the bug and verifies the fix, ensuring this issue does not recur.
There was a problem hiding this comment.
Pull request overview
Fixes an accounting bug in the scheduler’s proportion plugin where resources could be double-counted for gang-scheduled jobs whose tasks are in Binding (allocated) while the PodGroup phase remains Inqueue, causing queues to appear over capacity and block otherwise schedulable jobs.
Changes:
- Adjust proportion plugin inqueue accounting to subtract already-allocated resources from
minResourceswhen PodGroup isInqueue. - Add a regression test that reproduces the
Binding-window double-counting and verifies a second job can be enqueued and bound.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/scheduler/plugins/proportion/proportion.go | Updates PodGroupInqueue inqueue resource calculation to use util.GetInqueueResource(job, job.Allocated) to avoid double-counting. |
| pkg/scheduler/plugins/proportion/proportion_test.go | Adds a deterministic regression test covering the Binding window and a helper to wait for bind notifications. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…h binding tasks Signed-off-by: Aman-Cool <aman017102007@gmail.com>
c40d3cc to
6db3122
Compare
|
Hey @hajnalmt @JesseStutler @hzxuzhonghu, Traced this one down while looking at some scheduling delays; jobs were getting stuck in Pending even with free queue capacity. Turns out the proportion plugin was counting the same resources twice during the binding window. Let me know if you'd like any changes😄. |
There was a problem hiding this comment.
/retest
/lgtm
Thanks for the contrib! You have awesome findings! Both the problem and the solution is legit. Please port this to the capacity plugin too in an other PR if @JesseStutler agrees. It has the same bug as this one only at two places not just one 😄
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: hajnalmt The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@hajnalmt, Thanks so much! Really glad it checks out!😄 |
|
/kind scheduling 👍 |
|
@hajnalmt: The label(s) DetailsIn response to this:
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/test-infra repository. |
|
|
||
| // waitForBinds reads exactly n items from ch within deadline and returns them. | ||
| // It fails the test if fewer than n items arrive within the timeout. | ||
| func waitForBinds(t *testing.T, ch <-chan string, n int, timeout time.Duration) map[string]bool { |
There was a problem hiding this comment.
I wanted to mention that this shouldn't be here rather than in uthelper, but this is true for getLocalMetrics and getWorkerAffinity too. If you create a new PR for the capacity plugin please move these there too. You will need to have waitForBinds at a common a place anyway.
Also I am thinking that a big chunk of your unit test should be outsourced too. It does its job and I understand that your test does not align with our TestCommonStruct at all, due to the double session openings, but it looks sloppy 😄 Probably we need have a common way for double session tests.
There was a problem hiding this comment.
Makes sense! will keep this in mind while working on the capacity PR😄.
Thanks for bringing this up😁.
What type of PR is this?
bug fix
What this PR does / why we need it:
While investigating some scheduling issues I noticed that jobs can get stuck in Pending even when there's clearly enough queue capacity available. Tracked it down to a double-counting bug in the proportion plugin.
When a gang-scheduled job's tasks get allocated, they move to
Bindingstate in the scheduler cache. The problem is thatBindingis part ofAllocatedStatusbut notScheduledStatus, so the PodGroup staysInqueueuntil the tasks actually reachRunning. During this window, the proportion plugin counts those task resources in bothattr.allocatedandattr.inqueue— the fullminResourcesgets added toattr.inqueuewithout deducting what's already allocated.So if job-a uses 3 CPU on a 4 CPU queue, while its tasks are binding the queue looks like it's using 6 CPU, and any new job gets rejected even though there's 1 CPU free.
The
PodGroupRunningbranch already handles this correctly usingGetInqueueResource(job, job.Allocated)which returnsmax(0, minResources - already_allocated). Applied the same logic to thePodGroupInqueuebranch.Which issue(s) this PR fixes:
Fixes #5099
Special notes for your reviewer:
Added a regression test that runs two scheduler cycles against a shared cache, cycle 1 allocates job-a (3×1CPU) leaving its tasks in
Binding, cycle 2 tries to enqueue job-b (1×1CPU) on a 4 CPU queue. Without the fix the test times out waiting for job-b to be bound. With the fix it passes.Does this PR introduce a user-facing change?