Skip to content

[API] Add explicit StormService deployment mode field - #2450

Merged
googs1025 merged 4 commits into
vllm-project:mainfrom
V-3604:varshith/feat_stormservice_explicit_mode
Aug 25, 2026
Merged

googs1025 merged 4 commits into
vllm-project:mainfrom
V-3604:varshith/feat_stormservice_explicit_mode

Conversation

@V-3604

@V-3604 V-3604 commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request Description

StormService has no field that records its deployment mode. The controller drives behavior from spec.updateStrategy.type (RollingUpdate for the replica path, InPlaceUpdate for the pooled path in sync.go), and the autoscaler recovers the mode from the autoscaling.aibrix.ai/storm-service-mode annotation on the PodAutoscaler (workload_scale.go). The design doc defines the canonical rule (replicas > 1 is replica mode, replicas == 1 is pooled mode), but nothing on the resource encodes it, so replicas: 1 is ambiguous and role-level autoscaling needs a separate annotation to recover the intent.

This adds an explicit Mode field (Replica or Pooled) to StormServiceSpec and keeps it optional for backward compatibility:

  • StormServiceSpec.ResolvedMode() returns spec.mode when set, otherwise infers it from spec.replicas using the documented rule.
  • The validating webhook rejects mode: Pooled with spec.replicas > 1 on create and update, since pooled mode runs a single RoleSet and scales roles through spec.template.spec.roles[].replicas. Only an explicitly declared spec.mode is checked.

spec.mode is not defaulted. Recording an inferred mode on an object that never declared one would pin it: a pre-existing replicas: 1 StormService would get Pooled written during an unrelated update and then be blocked from scaling up. Objects that leave spec.mode empty keep the inferred behavior on both create and update.

The field is advisory in this change: it does not alter the controller update-path selection, which still keys off spec.updateStrategy.type. Moving the autoscaler to read spec.mode, with the annotation kept as a temporary fallback, is a focused follow-up so this stays reviewable. The design doc and the samples/autoscaling manifests are updated to declare spec.mode explicitly.

Generated CRDs and applyconfiguration were regenerated with the pinned controller-gen v0.16.1 and applyconfiguration-gen v0.31.8.

$ go test ./api/orchestration/v1alpha1/... ./pkg/webhook/... -run TestStormService
ok github.com/vllm-project/aibrix/api/orchestration/v1alpha1 0.140s
ok github.com/vllm-project/aibrix/pkg/webhook 0.185s

Related Issues

Resolves: #2449

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 an explicit mode field to StormServiceSpec and StormServiceStatus to support "Replica" and "Pooled" deployment modes, with backward compatibility defaulting based on the replica count. It updates CRDs, client configurations, documentation, and the controller, while adding webhook validation to prevent invalid replica configurations in pooled mode. The review feedback highlights a critical need to make the deployment mode immutable during updates to prevent disruptive controller reconciliation errors, and suggests adding a corresponding unit test to verify this validation.

Comment thread pkg/webhook/stormservice_webhook.go Resolved

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 an explicit spec.mode (Replica/Pooled) to the StormService API so deployment mode intent is no longer implicit/ambiguous (especially when replicas: 1). The change is reinforced via webhook defaulting/validation and surfaced via status.mode, with samples/docs updated accordingly.

Changes:

  • Introduce StormServiceMode + StormServiceSpec.ResolvedMode() and add spec.mode / status.mode fields.
  • Mutating/validating webhook records the resolved mode and validates mode/replicas constraints; controller reports mode into status.
  • Regenerate CRDs/applyconfig and update docs, samples, and webhook tests.

Reviewed changes

Copilot reviewed 10 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
api/orchestration/v1alpha1/stormservice_types.go Adds spec.mode, status.mode, StormServiceMode, and ResolvedMode() logic.
pkg/webhook/stormservice_webhook.go Defaults spec.mode; adds mode/replicas validation and (currently) mode immutability on update.
pkg/controller/stormservice/sync.go Reports resolved mode in status.mode.
pkg/webhook/stormservice_webhook_test.go Adds unit tests for mode defaulting, validation, and update behavior.
test/utils/wrapper/stormservice.go Adds wrapper helper to set Mode() in tests.
test/integration/webhook/stormservice_webhook_test.go Updates expected defaulted StormService to include spec.mode.
samples/autoscaling/stormservice-replica.yaml Explicitly sets spec.mode: Replica.
samples/autoscaling/stormservice-pool.yaml Explicitly sets spec.mode: Pooled.
docs/source/designs/aibrix-stormservice.rst Documents spec.mode defaulting behavior and status.mode.
config/crd/orchestration/orchestration.aibrix.ai_stormservices.yaml Regenerated CRD schema including spec.mode and status.mode.
dist/chart/crds/orchestration.aibrix.ai_stormservices.yaml Regenerated Helm CRD copy including spec.mode and status.mode.
pkg/client/applyconfiguration/orchestration/v1alpha1/stormservicespec.go Regenerated applyconfig to include spec.mode.
pkg/client/applyconfiguration/orchestration/v1alpha1/stormservicestatus.go Regenerated applyconfig to include status.mode.
Files not reviewed (2)
  • pkg/client/applyconfiguration/orchestration/v1alpha1/stormservicespec.go: Generated file
  • pkg/client/applyconfiguration/orchestration/v1alpha1/stormservicestatus.go: Generated file

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

Comment thread pkg/webhook/stormservice_webhook.go Outdated
Comment on lines +224 to +228
// The deployment mode selects the RoleSet topology the controller builds, so
// switching it on a live StormService would force a disruptive teardown and
// rebuild. Treat the resolved mode as immutable and require recreation instead.
// Comparing ResolvedMode rather than spec.Mode keeps objects created before the
// mode field existed (stored spec.mode is empty) from being rejected on updates.
Comment on lines +116 to +119
// Mode is the resolved deployment mode the controller is operating the StormService in.
// +optional
Mode StormServiceMode `json:"mode,omitempty"`


// Mode is the resolved deployment mode the controller is operating the StormService in.
// +optional
Mode StormServiceMode `json:"mode,omitempty"`

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.

I think we should drop status.mode from this change.

Once spec.mode exists, status.mode mostly duplicates spec.mode/ResolvedMode and creates an extra consistency contract. Since the controller still selects the execution path from
spec.updateStrategy.type in this PR, reporting status.mode as "the mode the controller is operating in" can be misleading. Keeping only spec.mode makes the API source of truth
clearer and avoids status/spec drift.

For observability, kubectl get -o yaml will already show spec.mode for newly defaulted objects. Legacy objects can still be interpreted through ResolvedMode() internally until they
are migrated.

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.

Dropped status.mode. Agreed it duplicates spec.mode without the controller acting on it, and ResolvedMode() covers legacy objects internally.

Comment thread pkg/webhook/stormservice_webhook.go Outdated
// rebuild. Treat the resolved mode as immutable and require recreation instead.
// Comparing ResolvedMode rather than spec.Mode keeps objects created before the
// mode field existed (stored spec.mode is empty) from being rejected on updates.
if oldStormService.Spec.ResolvedMode() != stormService.Spec.ResolvedMode() {

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.

This breaks compatibility for existing StormService objects.

For a pre-existing object without spec.mode, scaling from replicas: 1 to replicas: 3 used to be a valid operation. With this PR, ValidateUpdate rejects it as a resolved mode change.
There is also a second compatibility trap: because the mutating webhook runs on update, an old replicas: 1 object can get spec.mode defaulted to Pooled during an unrelated update, after which a later scale-up to replicas > 1 is rejected by the Pooled/replicas validation.

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.

Reverted the immutability check. Also dropped the spec.mode defaulting, since the second trap comes from that on its own: once Default() stamps Pooled on a replicas: 1 object, the Pooled/replicas rule blocks the later scale-up whether or not the immutability check is there. spec.mode is now user-declared only, so objects that don't set it behave exactly as before on create and update.

@googs1025
googs1025 force-pushed the varshith/feat_stormservice_explicit_mode branch from afb5eed to 0066fbd Compare July 18, 2026 13:31
Comment on lines +217 to +219
if err := validateStormServiceMode(stormService); err != nil {
return nil, err
}

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.

I found one API-boundary question that may need attention here. @Jeffwan could you also take a look and confirm whether this is something we need to cover?

validateStormServiceMode() covers normal StormService create/update, but does it also cover updates through the /scale subresource?

StormService exposes /scale with specpath=.spec.replicas, so clients like kubectl scale, HPA-style controllers, or external autoscalers can update replicas via stormservices/ scale. If that admission request carries an autoscaling/v1.Scale object instead of a full StormService, this helper may not run unless the webhook is explicitly registered for and handles the scale subresource.

This was not an invariant before spec.mode existed, because replicas > 1 simply inferred Replica mode. With this PR, explicit mode: Pooled introduces a new API invariant: spec.replicas must stay <= 1. Could we either verify that the current webhook catches /scale updates, or add coverage for that path so explicit mode: Pooled cannot be scaled above 1 through the scale API?

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.

Reasonable concern. I kind of forget the webhook behavior but I doubt we checked the scale resource earlier. this would be some improvement we can do later.

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.

Agreed, leaving it out of this PR. Nothing here changes the scale path, so stormservices/scale behaves as it did before spec.mode. I can open a separate issue for CEL enforcement on StormServiceSpec if needed.

@@ -205,11 +209,30 @@ func (r *StormServiceCustomDefaulter) ValidateCreate(ctx context.Context, obj ru
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type

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.

please also add case in test/integration/webhook

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.

Added in test/integration/webhook/stormservice_webhook_test.go: explicit Pooled with replicas: 2 rejected, explicit Pooled with one replica accepted, undeclared mode with replicas: 3 accepted, and a scale-up update on an explicit Pooled object 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.

only left two comments

@Jeffwan

Jeffwan commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

@googs1025 do you have changes requested? Assign to you to review and approve.

@googs1025

Copy link
Copy Markdown
Collaborator

@V-3604 Could you please take another look at the latest comments on this PR and confirm whether anything else needs to be updated?

@googs1025
googs1025 force-pushed the varshith/feat_stormservice_explicit_mode branch from 0066fbd to ced8213 Compare August 12, 2026 08:28
@googs1025

Copy link
Copy Markdown
Collaborator

@V-3604 are you still working on this? 😄

@V-3604

V-3604 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

@googs1025 I'm sorry abut the delay. Thanks for keeping the branch rebased.

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

This PR introduces the explicit mode field and preserves backward compatibility. Controller/autoscaler adoption and scale-subresource enforcement are follow-ups.

@googs1025
googs1025 merged commit 3e3aa00 into vllm-project:main Aug 25, 2026
18 checks passed
rishabhsinha17 added a commit to rishabhsinha17/aibrix that referenced this pull request Sep 2, 2026
…odAutoscaler

Follow-ups to vllm-project#2450 outlined in vllm-project#2449:

- The StormService controller now derives the rollout path from a declared
  spec.mode (Replica -> RollingUpdate path, Pooled -> InPlaceUpdate path)
  through EffectiveUpdateStrategyType. When spec.mode is unset the legacy
  updateStrategy.type selection is kept so existing manifests behave as
  before.
- The webhook rejects a declared mode: Replica combined with a declared
  updateStrategy.type: InPlaceUpdate. The reverse combination (Pooled with
  RollingUpdate) is not rejected because the CRD defaults
  spec.updateStrategy.type to RollingUpdate whenever the updateStrategy
  block is present, making a user-written RollingUpdate indistinguishable
  from the default; the controller resolves it in favor of the declared
  mode and logs the override.
- PodAutoscaler role-level scaling reads StormService.spec.mode as the
  source of truth. The autoscaling.aibrix.ai/storm-service-mode annotation
  is deprecated and only honored when the target StormService does not
  declare spec.mode. Samples and docs updated accordingly.

Signed-off-by: Rishabh Sinha <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
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.

Make StormService deployment mode explicit

4 participants