fix(scheduler): display maxFloat/maxInt in Resource.String() for infinite values#5276
fix(scheduler): display maxFloat/maxInt in Resource.String() for infinite values#5276r0hansaxena wants to merge 3 commits intovolcano-sh:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the String() method in pkg/scheduler/api/resource_info.go to handle sentinel values for CPU, memory, and scalar resources by returning 'maxFloat' or 'maxInt' strings. Feedback suggests improving efficiency by using strings.Builder instead of repeated fmt.Sprintf calls, and recommends a unified helper function to ensure consistent handling of both sentinel values across all resource types.
There was a problem hiding this comment.
Pull request overview
This PR improves scheduler log readability by updating (*Resource).String() to render “infinite/unbounded” sentinel values (math.MaxFloat64 / math.MaxInt64) as the short tokens maxFloat and maxInt instead of printing extremely large raw numbers.
Changes:
- Updated
Resource.String()to printmaxFloatfor CPU/memory when they aremath.MaxFloat64. - Updated
Resource.String()to printmaxIntfor scalar resources when they aremath.MaxInt64.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7507df3 to
fc2a5a2
Compare
Signed-off-by: r0hansaxena <rohansxn8772@gmail.com>
Signed-off-by: r0hansaxena <rohansxn8772@gmail.com>
Signed-off-by: r0hansaxena <rohansxn8772@gmail.com>
20a9dbe to
5c7260d
Compare
|
@hajnalmt please have a look |
hajnalmt
left a comment
There was a problem hiding this comment.
/lgtm
Thanks for the contribution!
| if val == math.MaxFloat64 { | ||
| return "maxFloat" | ||
| } | ||
| if val == float64(math.MaxInt64) { |
There was a problem hiding this comment.
I just realized how bad this conversion is here, these are maxInt float64 values for scalar resources, and we save maxInt64 in them. We need to write a new resource API on the long run definitely
|
[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 |
|
/area scheduling |
What type of PR is this?
kind/bug
What this PR does / why we need it:
Verbose scheduler logs were printing raw sentinel values like math.MaxFloat64
and math.MaxInt64 for unbounded resources, making the output near unreadable.
The String() method on Resource now shows "maxFloat" and "maxInt" in those
cases instead.
Which issue(s) this PR fixes:
Fixes #5148
Special notes for your reviewer:
Only the String() method is affected, no logic changes anywhere.
Does this PR introduce a user-facing change?