Skip to content

Commit 4475ce5

Browse files
committed
remove WithAutoscalerOptions and WithVersion + check nil only once
Signed-off-by: alimaazamat <alima.azamat2003@gmail.com>
1 parent abc35ba commit 4475ce5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

ray-operator/controllers/ray/utils/validation.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -581,13 +581,15 @@ func validateLegacyDeletionPolicies(rayJob *rayv1.RayJob) error {
581581
// validateWorkerGroupIdleTimeout validates the idleTimeoutSeconds field in a worker group spec
582582
func validateWorkerGroupIdleTimeout(workerGroup rayv1.WorkerGroupSpec, spec *rayv1.RayClusterSpec) error {
583583
idleTimeoutSeconds := workerGroup.IdleTimeoutSeconds
584-
if idleTimeoutSeconds != nil && *idleTimeoutSeconds < 0 {
585-
return fmt.Errorf("idleTimeoutSeconds must be non-negative, got %d", *idleTimeoutSeconds)
586-
}
584+
if idleTimeoutSeconds != nil {
585+
if *idleTimeoutSeconds < 0 {
586+
return fmt.Errorf("idleTimeoutSeconds must be non-negative, got %d", *idleTimeoutSeconds)
587+
}
587588

588-
// idleTimeoutSeconds only allowed on autoscaler v2
589-
if idleTimeoutSeconds != nil && !IsAutoscalingV2Enabled(spec) {
590-
return fmt.Errorf("worker group %s has idleTimeoutSeconds set, but autoscaler version is not v2. Please set .spec.autoscalerOptions.version to v2", workerGroup.GroupName)
589+
// idleTimeoutSeconds only allowed on autoscaler v2
590+
if !IsAutoscalingV2Enabled(spec) {
591+
return fmt.Errorf("worker group %s has idleTimeoutSeconds set, but autoscaler version is not v2. Please set .spec.autoscalerOptions.version to v2", workerGroup.GroupName)
592+
}
591593
}
592594

593595
return nil

ray-operator/test/e2eautoscaler/raycluster_autoscaler_part2_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ func TestRayClusterAutoscalerV2IdleTimeout(t *testing.T) {
4242
rayClusterSpecAC := rayv1ac.RayClusterSpec().
4343
WithEnableInTreeAutoscaling(true).
4444
WithRayVersion(GetRayVersion()).
45-
WithAutoscalerOptions(rayv1ac.AutoscalerOptions().
46-
WithVersion(rayv1.AutoscalerVersionV2)).
4745
WithHeadGroupSpec(rayv1ac.HeadGroupSpec().
4846
WithRayStartParams(map[string]string{"num-cpus": "0"}).
4947
WithTemplate(tc.HeadPodTemplateGetter())).

0 commit comments

Comments
 (0)