Skip to content

[release-1.15] fix: use milli-units for scalar in-queue resources - #5499

Merged
volcano-sh-bot merged 4 commits into
volcano-sh:release-1.15from
volcano-sh-bot:cherry-pick-5391-to-release-1.15
Jun 25, 2026
Merged

[release-1.15] fix: use milli-units for scalar in-queue resources#5499
volcano-sh-bot merged 4 commits into
volcano-sh:release-1.15from
volcano-sh-bot:cherry-pick-5391-to-release-1.15

Conversation

@volcano-sh-bot

Copy link
Copy Markdown
Contributor

This is an automated cherry-pick of #5391

Signed-off-by: WHOIM1205 <rathourprateek8@gmail.com>
…lar units

Signed-off-by: WHOIM1205 <rathourprateek8@gmail.com>
Signed-off-by: WHOIM1205 <rathourprateek8@gmail.com>
Signed-off-by: WHOIM1205 <rathourprateek8@gmail.com>
@volcano-sh-bot volcano-sh-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 24, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

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 refactors GetInqueueResource to use the canonical unit model when calculating reserved (in-queue) resources, ensuring scalar resources like GPUs (milli-units) and pods (whole units) are computed correctly. It also introduces a comprehensive suite of unit tests. The review feedback highlights a critical issue where job, job.PodGroup, job.PodGroup.Spec.MinResources, or allocated could be nil, potentially causing a nil pointer dereference panic, and provides a code suggestion to safely handle these cases.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines 97 to +98
func GetInqueueResource(job *api.JobInfo, allocated *api.Resource) *api.Resource {
minResources := api.NewResource(*job.PodGroup.Spec.MinResources)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The function GetInqueueResource dereferences job.PodGroup.Spec.MinResources without checking if job, job.PodGroup, or job.PodGroup.Spec.MinResources is nil. Since job.PodGroup can be nil (for example, after calling UnsetPodGroup), this can lead to a nil pointer dereference panic. Additionally, allocated should be checked for nil to prevent panics when accessing its fields.

func GetInqueueResource(job *api.JobInfo, allocated *api.Resource) *api.Resource {
	if job == nil || job.PodGroup == nil || job.PodGroup.Spec.MinResources == nil {
		return api.EmptyResource()
	}
	if allocated == nil {
		allocated = api.EmptyResource()
	}
	minResources := api.NewResource(*job.PodGroup.Spec.MinResources)

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.

This is valid but I don't think this needs to block this cherry-pick.

The production call sites already dereference job.PodGroup and check job.PodGroup.Spec.MinResources != nil before calling GetInqueueResource, and scheduler snapshots skip jobs without PodGroups. allocated is passed as job.Allocated, which is initialized on JobInfo.

So the nil check would only make this helper more defensive for artificial/direct calls; it would not fix a currently reachable panic path introduced by this PR. Since this is a release-branch cherry-pick, I prefer keeping it focused on the scalar-resource accounting fix.

@hajnalmt hajnalmt left a comment

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.

/lgtm
/approve
/label tide/merge-method-squash

Comment on lines 97 to +98
func GetInqueueResource(job *api.JobInfo, allocated *api.Resource) *api.Resource {
minResources := api.NewResource(*job.PodGroup.Spec.MinResources)

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.

This is valid but I don't think this needs to block this cherry-pick.

The production call sites already dereference job.PodGroup and check job.PodGroup.Spec.MinResources != nil before calling GetInqueueResource, and scheduler snapshots skip jobs without PodGroups. allocated is passed as job.Allocated, which is initialized on JobInfo.

So the nil check would only make this helper more defensive for artificial/direct calls; it would not fix a currently reachable panic path introduced by this PR. Since this is a release-branch cherry-pick, I prefer keeping it focused on the scalar-resource accounting fix.

@volcano-sh-bot volcano-sh-bot added tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. lgtm Indicates that a PR is ready to be merged. labels Jun 24, 2026
@JesseStutler

Copy link
Copy Markdown
Member

/approve

@volcano-sh-bot

Copy link
Copy Markdown
Contributor Author

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hajnalmt, JesseStutler

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

@volcano-sh-bot volcano-sh-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 25, 2026
@volcano-sh-bot
volcano-sh-bot merged commit e945225 into volcano-sh:release-1.15 Jun 25, 2026
29 checks passed
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. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 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.

4 participants