Skip to content

Conversation

@linuxfhy
Copy link
Member

…no.sh/gpu-number resources

What type of PR is this?

fix

Which issue(s) this PR fixes:

Fixes #4499

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

…no.sh/gpu-number resources

Signed-off-by: fanhy36 <[email protected]>
Signed-off-by: linuxfhy <[email protected]>
@volcano-sh-bot volcano-sh-bot requested review from Thor-wl and k82cn July 29, 2025 16:58
Copy link

@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.

Summary of Changes

Hello @linuxfhy, 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 scheduler panic that occurs during an upgrade path from Volcano 1.7 to Volcano 1.12, specifically when pods previously scheduled with volcano.sh/gpu-number resources are involved. The fix prevents the scheduler from crashing by safely handling resource access, ensuring stability during such transitions.

Highlights

  • Scheduler Panic Fix: Implemented a fix to prevent a scheduler panic that arises when upgrading from Volcano 1.7 (using volcano.sh/gpu-number resources) to Volcano 1.12 (with Hami device plugin and VGPUEnable).
  • Conditional Resource Access: Introduced conditional checks (if gpushare.GpuSharingEnable || gpushare.GpuNumberEnable) in addResource and subResource functions within pkg/scheduler/api/node_info.go.
  • Improved Upgrade Stability: Ensures that the scheduler can gracefully handle scenarios where gpushare.DeviceName resources might not be initialized as expected, thereby improving the robustness of the system during version upgrades.
Using Gemini Code Assist

The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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 or fill out our survey to provide feedback.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@volcano-sh-bot volcano-sh-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 29, 2025
Copy link

@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

The pull request aims to fix a scheduler panic that occurs during an upgrade. The provided fix is specific to the described scenario but introduces a potential panic in other valid configurations. I've suggested a more robust solution that addresses the underlying issue of unsafe device access for both gpushare and vgpu devices, preventing panics across different configurations. The same logic applies to both addResource and subResource functions.

Comment on lines +511 to 514
if gpushare.GpuSharingEnable || gpushare.GpuNumberEnable {
ni.Others[gpushare.DeviceName].(Devices).SubResource(pod)
}
ni.Others[vgpu.DeviceName].(Devices).SubResource(pod)

Choose a reason for hiding this comment

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

high

Similar to addResource, this fix is incomplete and can lead to a panic. The call to SubResource for vgpu on line 514 is not guarded and will cause a panic if vgpu is disabled and ni.Others[vgpu.DeviceName] is nil.

For robust error handling, this call should be protected by checking the vgpu.VGPUEnable flag, and a safe type assertion should be used to prevent panics from nil device objects.

    if gpushare.GpuSharingEnable || gpushare.GpuNumberEnable {
        if dev, ok := ni.Others[gpushare.DeviceName].(Devices); ok && dev != nil {
            dev.SubResource(pod)
        }
    }
    if vgpu.VGPUEnable {
        if dev, ok := ni.Others[vgpu.DeviceName].(Devices); ok && dev != nil {
            dev.SubResource(pod)
        }
    }

Copy link
Member

Choose a reason for hiding this comment

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

@linuxfhy Please check it, Gemini is correct.

Copy link
Member Author

@linuxfhy linuxfhy Aug 1, 2025

Choose a reason for hiding this comment

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

@JesseStutler There is no need, as Volcano v1.7 does not use the vgpu strategy's corresponding resource (volcano.sh/vgpu-number), so there won't be any issues. Moreover, the implementation of the AddResource function under the vgpu strategy already includes a check for an empty gs, providing a double safeguard.

Copy link
Member

Choose a reason for hiding this comment

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

It's better to check it.

Copy link
Member

Choose a reason for hiding this comment

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

I'm OK with it, but we'd better add a if judgement; it will be more clear

@linuxfhy linuxfhy changed the title fix #4499: scheduler panic caused by pod using gpu-number scheduled by volcano 1.7 fix #4499: scheduler panic caused by pod using gpu-number scheduled by volcano with old version (e.g v1.7) Jul 29, 2025
@Monokaix
Copy link
Member

Monokaix commented Aug 4, 2025

/approve

@volcano-sh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Monokaix

The full list of commands accepted by this bot can be found here.

The pull request process is described here

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 Aug 4, 2025
@Monokaix
Copy link
Member

Monokaix commented Aug 4, 2025

Please also cherry-pick to release 1.1 and 1.12 after merged.

Copy link
Member

@JesseStutler JesseStutler left a comment

Choose a reason for hiding this comment

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

/lgtm

@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 4, 2025
@volcano-sh-bot volcano-sh-bot merged commit 8b9003f into volcano-sh:master Aug 4, 2025
18 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/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

volcano 1.12 scheduler panic caused by pod scheduled by volcano 1.7 and using volcano.sh/gpu-number resources

5 participants