-
Notifications
You must be signed in to change notification settings - Fork 691
Fix: Move replica validation logic to right place. #4307
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,11 +111,30 @@ func ValidateRayClusterSpec(spec *rayv1.RayClusterSpec, annotations map[string]s | |
| return err | ||
| } | ||
|
|
||
| // Check if autoscaling is enabled once to avoid repeated calls | ||
| isAutoscalingEnabled := IsAutoscalingEnabled(spec) | ||
|
|
||
| for _, workerGroup := range spec.WorkerGroupSpecs { | ||
| if len(workerGroup.Template.Spec.Containers) == 0 { | ||
| return fmt.Errorf("workerGroupSpec should have at least one container") | ||
| } | ||
|
|
||
| // When autoscaling is enabled, MinReplicas and MaxReplicas are optional | ||
| // as users can manually update them and the autoscaler will handle the adjustment. | ||
| if !isAutoscalingEnabled && (workerGroup.MinReplicas == nil || workerGroup.MaxReplicas == nil) { | ||
| return fmt.Errorf("worker group %s must set both minReplicas and maxReplicas when autoscaling is disabled", workerGroup.GroupName) | ||
| } | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if workerGroup.MinReplicas != nil && *workerGroup.MinReplicas < 0 { | ||
| return fmt.Errorf("worker group %s has negative minReplicas %d", workerGroup.GroupName, *workerGroup.MinReplicas) | ||
| } | ||
| if workerGroup.MaxReplicas != nil && *workerGroup.MaxReplicas < 0 { | ||
| return fmt.Errorf("worker group %s has negative maxReplicas %d", workerGroup.GroupName, *workerGroup.MaxReplicas) | ||
| } | ||
| if workerGroup.MinReplicas != nil && workerGroup.MaxReplicas != nil { | ||
| if *workerGroup.MinReplicas > *workerGroup.MaxReplicas { | ||
| return fmt.Errorf("worker group %s has minReplicas %d greater than maxReplicas %d", workerGroup.GroupName, *workerGroup.MinReplicas, *workerGroup.MaxReplicas) | ||
| } | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also check if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @machichima Here in the So I think that here in
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to confirm: |
||
| if err := validateRayGroupResources(workerGroup.GroupName, workerGroup.RayStartParams, workerGroup.Resources); err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -175,9 +194,6 @@ func ValidateRayClusterSpec(spec *rayv1.RayClusterSpec, annotations map[string]s | |
| } | ||
| } | ||
|
|
||
| // Check if autoscaling is enabled once to avoid repeated calls | ||
| isAutoscalingEnabled := IsAutoscalingEnabled(spec) | ||
|
|
||
| // Validate that RAY_enable_autoscaler_v2 environment variable is not set to "1" or "true" when autoscaler is disabled | ||
| if !isAutoscalingEnabled { | ||
| if envVar, exists := EnvVarByName(RAY_ENABLE_AUTOSCALER_V2, spec.HeadGroupSpec.Template.Spec.Containers[RayContainerIndex].Env); exists { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.