Skip to content

Commit d76a861

Browse files
alimaazamatwin5923
andcommitted
Check spec version then fall back to env var
Co-authored-by: Jun-Hao Wan <ken89@kimo.com> Signed-off-by: Alima Azamat <92766804+alimaazamat@users.noreply.github.com> Signed-off-by: alimaazamat <alima.azamat2003@gmail.com>
1 parent a608d94 commit d76a861

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,14 @@ func validateWorkerGroupIdleTimeout(workerGroup rayv1.WorkerGroupSpec, spec *ray
609609
}
610610

611611
// idleTimeoutSeconds only allowed on autoscaler v2
612+
if IsAutoscalingV2Enabled(spec) {
613+
return nil
614+
}
612615
envVar, exists := EnvVarByName(RAY_ENABLE_AUTOSCALER_V2, spec.HeadGroupSpec.Template.Spec.Containers[RayContainerIndex].Env)
613-
if !exists || (envVar.Value != "1" && envVar.Value != "true") {
614-
return fmt.Errorf("worker group %s has idleTimeoutSeconds set, but %s environment variable is not set to 'true' in the head pod", workerGroup.GroupName, RAY_ENABLE_AUTOSCALER_V2)
616+
if exists && (envVar.Value == "1" || envVar.Value == "true") {
617+
return nil
615618
}
619+
return fmt.Errorf("worker group %s has idleTimeoutSeconds set, but autoscaler v2 is not enabled. Please set .spec.autoscalerOptions.version to 'v2' (or set %s environment variable to 'true' in the head pod if using KubeRay < 1.4.0)", workerGroup.GroupName, RAY_ENABLE_AUTOSCALER_V2)
616620
}
617621

618622
return nil

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,7 @@ func TestValidateWorkerGroupIdleTimeout(t *testing.T) {
19641964
},
19651965
},
19661966
},
1967-
expectedErr: "worker group worker-group-1 has idleTimeoutSeconds set, but RAY_enable_autoscaler_v2 environment variable is not set to 'true' in the head pod",
1967+
expectedErr: fmt.Sprintf("worker group worker-group-1 has idleTimeoutSeconds set, but autoscaler v2 is not enabled. Please set .spec.autoscalerOptions.version to 'v2' (or set %s environment variable to 'true' in the head pod if using KubeRay < 1.4.0)", RAY_ENABLE_AUTOSCALER_V2),
19681968
},
19691969
"should reject idleTimeoutSeconds when autoscaler version is not set": {
19701970
spec: rayv1.RayClusterSpec{
@@ -1982,7 +1982,7 @@ func TestValidateWorkerGroupIdleTimeout(t *testing.T) {
19821982
},
19831983
},
19841984
},
1985-
expectedErr: "worker group worker-group-1 has idleTimeoutSeconds set, but RAY_enable_autoscaler_v2 environment variable is not set to 'true' in the head pod",
1985+
expectedErr: fmt.Sprintf("worker group worker-group-1 has idleTimeoutSeconds set, but autoscaler v2 is not enabled. Please set .spec.autoscalerOptions.version to 'v2' (or set %s environment variable to 'true' in the head pod if using KubeRay < 1.4.0)", RAY_ENABLE_AUTOSCALER_V2),
19861986
},
19871987
"should reject idleTimeoutSeconds when AutoscalerOptions is nil": {
19881988
spec: rayv1.RayClusterSpec{
@@ -2000,7 +2000,7 @@ func TestValidateWorkerGroupIdleTimeout(t *testing.T) {
20002000
},
20012001
},
20022002
},
2003-
expectedErr: "worker group worker-group-1 has idleTimeoutSeconds set, but RAY_enable_autoscaler_v2 environment variable is not set to 'true' in the head pod",
2003+
expectedErr: fmt.Sprintf("worker group worker-group-1 has idleTimeoutSeconds set, but autoscaler v2 is not enabled. Please set .spec.autoscalerOptions.version to 'v2' (or set %s environment variable to 'true' in the head pod if using KubeRay < 1.4.0)", RAY_ENABLE_AUTOSCALER_V2),
20042004
},
20052005
"should reject idleTimeoutSeconds when env var is set to invalid value": {
20062006
spec: rayv1.RayClusterSpec{
@@ -2020,7 +2020,7 @@ func TestValidateWorkerGroupIdleTimeout(t *testing.T) {
20202020
},
20212021
},
20222022
},
2023-
expectedErr: "worker group worker-group-1 has idleTimeoutSeconds set, but RAY_enable_autoscaler_v2 environment variable is not set to 'true' in the head pod",
2023+
expectedErr: fmt.Sprintf("worker group worker-group-1 has idleTimeoutSeconds set, but autoscaler v2 is not enabled. Please set .spec.autoscalerOptions.version to 'v2' (or set %s environment variable to 'true' in the head pod if using KubeRay < 1.4.0)", RAY_ENABLE_AUTOSCALER_V2),
20242024
},
20252025
"should accept worker group with idleTimeoutSeconds when env var is set to true": {
20262026
spec: rayv1.RayClusterSpec{

0 commit comments

Comments
 (0)