Skip to content

[Bug] Reject invalid Volcano gang scheduling configuration in StormService webhook - #2629

Merged
googs1025 merged 3 commits into
vllm-project:mainfrom
yaojiejia:yaojiejia/feat-volcano-gang-validation
Aug 30, 2026
Merged

googs1025 merged 3 commits into
vllm-project:mainfrom
yaojiejia:yaojiejia/feat-volcano-gang-validation

Conversation

@yaojiejia

Copy link
Copy Markdown
Contributor

Pull Request Description

The StormService webhook now rejects Volcano gang scheduling configurations that the controller or Volcano cannot accept, instead of silently accepting them:

  • volcanoSchedulingStrategy.minMember must be greater than 0.
  • Every minTaskMember value must be greater than 0.
  • Every minTaskMember key must match a role name (for a Role-level strategy, only that role's own name).
  • minMember must not be smaller than the sum of minTaskMember values, since Volcano skips all per-task checks otherwise.
  • spec.template.spec.schedulingStrategy and roles[].schedulingStrategy cannot be set together; the controller treats them as mutually exclusive.

All violations are returned in one Invalid error with field paths. On update, the check only runs when the RoleSet template changed, so objects created before this validation can still be updated and deleted.

Testing: unit tests in pkg/webhook/stormservice_webhook_test.go cover every rule and the update ratcheting; golangci-lint and go build ./... pass.

Related Issues

Resolves: #2619 scope 1

Important: Before submitting, please complete the description above and review the checklist below.


Contribution Guidelines (Expand for Details)

We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:

Pull Request Title Format

Your PR title should start with one of these prefixes to indicate the nature of the change:

  • [Bug]: Corrections to existing functionality
  • [CI]: Changes to build process or CI pipeline
  • [Docs]: Updates or additions to documentation
  • [API]: Modifications to aibrix's API or interface
  • [CLI]: Changes or additions to the Command Line Interface
  • [Misc]: For changes not covered above (use sparingly)

Note: For changes spanning multiple categories, use multiple prefixes in order of importance.

Submission Checklist

  • PR title includes appropriate prefix(es)
  • Changes are clearly explained in the PR description
  • New and existing tests pass successfully
  • Code adheres to project style and best practices
  • Documentation updated to reflect changes (if applicable)
  • Thorough testing completed, no regressions introduced

By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.

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

Copy link
Copy Markdown
Contributor

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 introduces validation for Volcano scheduling strategies within the StormService webhook, ensuring configurations like minMember and minTaskMember are valid and mutually exclusive when defined at both the RoleSet and Role levels. It also includes comprehensive unit tests to verify these validation rules. Feedback on the changes suggests adding a nil check on the old object during updates to prevent potential nil pointer dereference panics, and setting taskMembersValid to false when a task name is invalid to avoid misleading validation errors regarding the sum of task members.

Comment thread pkg/webhook/stormservice_webhook.go Outdated
Comment on lines +233 to +234
oldStormService, ok := oldObj.(*orchestrationv1alpha1.StormService)
if !ok || !equality.Semantic.DeepEqual(oldStormService.Spec.Template.Spec, stormService.Spec.Template.Spec) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To prevent potential nil pointer dereference panics (e.g., if oldObj is a typed nil pointer, where the type assertion succeeds but the value is nil), we should explicitly check if oldStormService is nil before accessing its fields.

Suggested change
oldStormService, ok := oldObj.(*orchestrationv1alpha1.StormService)
if !ok || !equality.Semantic.DeepEqual(oldStormService.Spec.Template.Spec, stormService.Spec.Template.Spec) {
oldStormService, ok := oldObj.(*orchestrationv1alpha1.StormService)
if !ok || oldStormService == nil || !equality.Semantic.DeepEqual(oldStormService.Spec.Template.Spec, stormService.Spec.Template.Spec) {

Comment on lines +338 to +341
if !taskNames.Has(key) {
allErrs = append(allErrs, field.Invalid(keyPath, key,
fmt.Sprintf("must match a role name; valid names are: %s", strings.Join(sets.List(taskNames), ", "))))
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

If a minTaskMember key does not match any valid role name, the task member configuration is invalid. We should set taskMembersValid = false to prevent triggering the subsequent minMember sum validation error, which would otherwise include the invalid key's value in the sum and produce a confusing error message.

Suggested change
if !taskNames.Has(key) {
allErrs = append(allErrs, field.Invalid(keyPath, key,
fmt.Sprintf("must match a role name; valid names are: %s", strings.Join(sets.List(taskNames), ", "))))
}
if !taskNames.Has(key) {
taskMembersValid = false
allErrs = append(allErrs, field.Invalid(keyPath, key,
fmt.Sprintf("must match a role name; valid names are: %s", strings.Join(sets.List(taskNames), ", "))))
}

@googs1025 googs1025 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

plz also add integration test case : in test/integration/webhook

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds webhook validation to reject invalid Volcano gang scheduling configurations on StormService RoleSet templates, returning aggregated Invalid errors with precise field paths. Update-time validation is intended to be “ratcheted” so pre-existing invalid objects can still receive metadata-only updates (e.g., finalizer removal).

Changes:

  • Validate Volcano gang scheduling fields (minMember, minTaskMember values/keys, and minMember vs minTaskMember sum) and reject invalid configs via apierrors.NewInvalid.
  • Reject mixed RoleSet-level and Role-level schedulingStrategy as mutually exclusive.
  • Add unit tests covering each rule and the update ratcheting behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/webhook/stormservice_webhook.go Adds scheduling strategy validation and update-time ratcheting logic.
pkg/webhook/stormservice_webhook_test.go Adds unit tests for validation rules and update behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/webhook/stormservice_webhook.go Outdated
Comment on lines +230 to +238
// Re-validate the scheduling strategy only when the RoleSet template changed. Objects that
// predate this validation must keep accepting metadata-only updates, in particular the
// controller's finalizer removal, or they could never be deleted.
oldStormService, ok := oldObj.(*orchestrationv1alpha1.StormService)
if !ok || !equality.Semantic.DeepEqual(oldStormService.Spec.Template.Spec, stormService.Spec.Template.Spec) {
if err := validateStormServiceSchedulingStrategy(stormService); err != nil {
return nil, err
}
}
@yaojiejia

Copy link
Copy Markdown
Contributor Author

plz also add integration test case : in test/integration/webhook

just added

@yaojiejia
yaojiejia force-pushed the yaojiejia/feat-volcano-gang-validation branch from 9f20d14 to 55acdee Compare August 28, 2026 02:08
@yaojiejia
yaojiejia force-pushed the yaojiejia/feat-volcano-gang-validation branch from 55acdee to 8582d6b Compare August 28, 2026 02:12

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *StormServiceCustomDefaulter) ValidateUpdate(_ context.Context, _, newObj runtime.Object) (admission.Warnings, error) {
func (r *StormServiceCustomDefaulter) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe we can narrow this update-time ratcheting check instead of comparing the whole Template.Spec.

I don't think we should skip scheduling validation on update completely, because a user could create a valid StormService and later update it into an invalid Volcano gang config. But comparing the whole template seems broader than this validation needs: sidecar defaulting or unrelated role/template changes could make an old object fail the new validation even when the scheduling config was not touched.

Would it be better to rerun validateStormServiceSchedulingStrategy only when the fields it depends on changed, e.g. the RoleSet-level schedulingStrategy, role names, or each role's schedulingStrategy?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, just updated to re run the scheduling validation only when the RoleSet-level strategy, a role name, or a role's strategy changes. Unrelated template changes and sidecar injection no longer trigger it, and editing a valid object into an invalid gang config is still rejected.

@googs1025 googs1025 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. thanks for this fix

@googs1025
googs1025 merged commit ae34825 into vllm-project:main Aug 30, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve StormService Volcano gang usability with validation and schedulerName injection

3 participants