Skip to content

fix(scheduler): display maxFloat/maxInt in Resource.String() for infinite values#5276

Open
r0hansaxena wants to merge 3 commits intovolcano-sh:masterfrom
r0hansaxena:fmt-resource-inf
Open

fix(scheduler): display maxFloat/maxInt in Resource.String() for infinite values#5276
r0hansaxena wants to merge 3 commits intovolcano-sh:masterfrom
r0hansaxena:fmt-resource-inf

Conversation

@r0hansaxena
Copy link
Copy Markdown

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?

Copilot AI review requested due to automatic review settings May 4, 2026 15:40
@volcano-sh-bot volcano-sh-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 4, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a 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 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.

Comment thread pkg/scheduler/api/resource_info.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 print maxFloat for CPU/memory when they are math.MaxFloat64.
  • Updated Resource.String() to print maxInt for scalar resources when they are math.MaxInt64.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/scheduler/api/resource_info.go Outdated
@volcano-sh-bot volcano-sh-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. do-not-merge/contains-merge-commits and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 4, 2026
Signed-off-by: r0hansaxena <rohansxn8772@gmail.com>
Signed-off-by: r0hansaxena <rohansxn8772@gmail.com>
Signed-off-by: r0hansaxena <rohansxn8772@gmail.com>
@r0hansaxena
Copy link
Copy Markdown
Author

@hajnalmt please have a look

Copy link
Copy Markdown
Member

@hajnalmt hajnalmt left a comment

Choose a reason for hiding this comment

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

/lgtm

Thanks for the contribution!

if val == math.MaxFloat64 {
return "maxFloat"
}
if val == float64(math.MaxInt64) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label May 5, 2026
@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hajnalmt
Once this PR has been reviewed and has the lgtm label, please assign k82cn for approval. For more information see the Kubernetes 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

@hajnalmt
Copy link
Copy Markdown
Member

hajnalmt commented May 5, 2026

/area scheduling
/label tide/merge-method-squash

@volcano-sh-bot volcano-sh-bot added area/scheduling tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. labels May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/scheduling lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Noisy log outputs on realCapability and capability due to maxFloat and maxInt

4 participants