-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: Volcano scheduler panic when scheduling Pods with delayed binding PVCs #4484
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
Conversation
…g PVCs Signed-off-by: ouyangshengjia <[email protected]>
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.
Summary of Changes
Hello @ouyangshengjia, 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 provides a crucial bug fix for the Volcano scheduler, resolving a panic that previously occurred when scheduling Pods that use delayed binding PersistentVolumeClaims. The root cause was an attempt to perform storage capacity checks even when the CSI storage feature was explicitly disabled. The changes introduce a safeguard to prevent these unnecessary checks under such conditions, thereby ensuring the scheduler's stability and correct operation.
Highlights
- Bug Fix: Addresses a critical panic in the Volcano scheduler that occurred when scheduling Pods with delayed binding PersistentVolumeClaims (PVCs), specifically when the
--csi-storagefeature was disabled (which is its default setting). - Conditional Logic: Introduces a new conditional check at the beginning of the
hasEnoughCapacityfunction inpkg/scheduler/capabilities/volumebinding/binder.go. This check ensures that ifcapacityCheckEnabledisfalse, the function immediately returnstrue(indicating sufficient capacity) andnilfor capacity and error, bypassing the problematic capacity check logic. - Testing: Adds a new unit test,
TestBinderWithCapacityCheckDisabled, topkg/scheduler/capabilities/volumebinding/binder_test.go. This test verifies that thehasEnoughCapacityfunction behaves as expected when the capacity check feature is disabled, confirming the bug fix.
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
-
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. ↩
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 fixes a panic in the Volcano scheduler that occurs when scheduling pods with delayed binding PVCs and CSI storage is disabled. The fix involves adding a check to bypass capacity validation when the feature is disabled, which prevents a nil pointer dereference. A new test case has been added to cover this scenario, and I've suggested an improvement to this test to make it more robust. Overall, the change is good and addresses the reported issue effectively.
| // This is an optional feature. If disabled, we assume that | ||
| // there is enough storage. | ||
| if !b.capacityCheckEnabled { | ||
| return true, nil, nil | ||
| } |
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.
| func TestBinderWithCapacityCheckDisabled(t *testing.T) { | ||
| logger, ctx := ktesting.NewTestContext(t) | ||
| ctx, cancel := context.WithCancel(ctx) | ||
| defer cancel() | ||
|
|
||
| binder := &volumeBinder{ | ||
| capacityCheckEnabled: false, | ||
| } | ||
| sufficient, _, err := binder.hasEnoughCapacity(logger, "", nil, nil, nil) | ||
| if err != nil { | ||
| t.Errorf("returned error: %v", err) | ||
| } | ||
| if !sufficient { | ||
| t.Error("expected sufficient, got insufficient") | ||
| } | ||
| } |
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.
While this test passes with the fix, it's a bit brittle because it passes nil for the claim parameter. This would cause a panic on claim.Spec if the capacityCheckEnabled check wasn't at the very beginning of the function.
To make the test more robust and accurately reflect the scenario that caused the original panic (accessing a nil csiDriverLister), it would be better to pass a valid claim with a storage request. This ensures we are testing the intended logic path.
This change will make the test more resilient to future code refactoring.
logger, ctx := ktesting.NewTestContext(t)
ctx, cancel := context.WithCancel(ctx)
defer cancel()
binder := &volumeBinder{
capacityCheckEnabled: false,
}
// A PVC with a storage request is needed to get past the first check in hasEnoughCapacity
// and properly test the scenario where csiDriverLister would be accessed.
pvc := makeTestPVC("test-pvc", "1Gi", "", pvcUnbound, "", "1", &waitClassWithProvisioner)
sufficient, _, err := binder.hasEnoughCapacity(logger, provisioner, pvc, &storagev1.StorageClass{}, nil)
if err != nil {
t.Errorf("returned error: %v", err)
}
if !sufficient {
t.Error("expected sufficient, got insufficient")
}|
/lgtm |
|
/approve |
|
[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 |
|
Please also cherry-pick to release1.12 |
@Monokaix This bug was introduced by the feature "adapt k8s 1.33". It does not exist in release1.12. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
volcano-scheduler with the startup argument
--csi-storage=false(the argument defaults false), will panic when scheduling Pods with delayed binding PVCs.Which issue(s) this PR fixes:
Fixes #4480
Special notes for your reviewer:
@JesseStutler
Does this PR introduce a user-facing change?