Skip to content

Commit 3fada64

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

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
@@ -603,13 +603,15 @@ func validateLegacyDeletionPolicies(rayJob *rayv1.RayJob) error {
603603
// validateWorkerGroupIdleTimeout validates the idleTimeoutSeconds field in a worker group spec
604604
func validateWorkerGroupIdleTimeout(workerGroup rayv1.WorkerGroupSpec, spec *rayv1.RayClusterSpec) error {
605605
idleTimeoutSeconds := workerGroup.IdleTimeoutSeconds
606-
if idleTimeoutSeconds != nil && *idleTimeoutSeconds < 0 {
607-
return fmt.Errorf("idleTimeoutSeconds must be non-negative, got %d", *idleTimeoutSeconds)
608-
}
606+
if idleTimeoutSeconds != nil {
607+
if *idleTimeoutSeconds < 0 {
608+
return fmt.Errorf("idleTimeoutSeconds must be non-negative, got %d", *idleTimeoutSeconds)
609+
}
609610

610-
// idleTimeoutSeconds only allowed on autoscaler v2
611-
if idleTimeoutSeconds != nil && !IsAutoscalingV2Enabled(spec) {
612-
return fmt.Errorf("worker group %s has idleTimeoutSeconds set, but autoscaler version is not v2. Please set .spec.autoscalerOptions.version to v2", workerGroup.GroupName)
611+
// idleTimeoutSeconds only allowed on autoscaler v2
612+
if !IsAutoscalingV2Enabled(spec) {
613+
return fmt.Errorf("worker group %s has idleTimeoutSeconds set, but autoscaler version is not v2. Please set .spec.autoscalerOptions.version to v2", workerGroup.GroupName)
614+
}
613615
}
614616

615617
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)