-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix Infinity Mode Logic in Resource Comparison Functions #4893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @zhifei92, 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 resolves a critical bug in the resource comparison logic within the scheduler's API, specifically affecting the 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. 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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly identifies and removes a logic bug in Less and LessEqual functions where they would incorrectly return false in Infinity mode if the left-hand resource was missing a scalar dimension present in the right-hand one. This is a crucial fix to prevent incorrect pod evictions.
However, while the incorrect logic is removed, the implementation is still incomplete. The functions now fail to check for resource dimensions that are present in the right-hand resource (rr) but not in the left-hand one (r). According to the intended logic, a missing dimension in r should be treated as zero. I've added suggestions to both functions to complete the logic by iterating over rr's resources as well. This is critical for ensuring the correctness of these comparison functions.
|
The LessEqual method that propagates the infinity parameter throughout the project is only used in the capacity plugin. |
|
/cc |
|
Looks like consider not set as zero is more reasonable, don't know why #2637 is more willing to consider not set as inifity. /cc @kingeasternsun |
|
@zhifei92 Hi, please don't forget to sign off your commit using |
d968f53 to
c05ae7b
Compare
done |
c05ae7b to
5dd978a
Compare
|
The CI failure doesn't seem to be caused by this PR. I'll update it after https://github.com/volcano-sh/volcano/pull/4914/changes is merged. |
|
/retest |
|
@zhifei92 I updated the code first and give CIs a try, but I don't hope we should keep a merge commit, you can rebase the latest code and push again |
…correct pod evictions. Signed-off-by: zhangzhifei16 <[email protected]>
cb95699 to
a03d79f
Compare
done |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JesseStutler The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/hold
/cc @kingeasternsun
Sry I missed this PR.
Let's start a discussion here, I think the function works correctly and by that I mean it's working as designed.
It was added in this PR:
#2637
(I added kingeasternsun due to this.)
The problem comes from misusing the function in the capacity plugin in the comparision you mentioned. This is the only place where we compare with api.Infinity hence the problem arose. But design-wise I think, if the left value is not defined in the resource comparsion we should return False when you provide api.Infinity to the function.
The bug you mentioned is actually pretty serious. We are overreclaiming now below deserved.
|
Okay, I checked the code on my prod env about what did I do here. It feels hacky still, but it actually solves this issue too so I have raised a PR in the end, based on this change and tried to summerize the issues I have met during the development of this here: |
Thanks mate you reminded me, I think we'd rather use |
As @hajnalmt mentioned in #4918 bug1, I do think we wrongfully didn't consider the resources reclaimer request, only compares the allocated and deserverd(but we still need to compare the allocated and deserved), we just need to add more judgements that we need to also judge that whether the scheduler has already reclaimed enough resources for the reclaimer |
|
Okay, I think I managed to bring this to a much more acceptable form: |
Thanks! I'd prefer to follow the way in #4919 |
What type of PR is this?
/kind bug
What this PR does / why we need it:
The
LessEqualandLess(even though it's no longer used anywhere.) functions inpkg/scheduler/api/resource_info.gohave an incorrect logic when usingInfinitymode. When the left resource (r) is missing a scalar resource dimension (e.g., GPU) but the right resource (rr) has it, the function incorrectly returnsfalse.Expected Behavior
When
rdoesn't have a dimension thatrrhas, it should be treated asr[dimension] = 0, and the comparison should continue (e.g.,0 <= rr[dimension]returnstrue).Actual Behavior (Before Fix)
The function returns
falseimmediately, treating the missing dimension as ifrexceedsrr, which is semantically incorrect.Root Cause
The problematic code :
volcano/pkg/scheduler/api/resource_info.go
Lines 416 to 422 in 3568eee
This logic enforces that
rmust contain all dimensions present inrr.Impact and Necessity of Fix
1. Incorrect Eviction in Capacity Plugin
The most critical impact is in the capacity plugin's reclaim logic:
volcano/pkg/scheduler/plugins/capacity/capacity.go
Lines 123 to 127 in 3568eee
Bug Scenario:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?