Skip to content

Commit a7197c5

Browse files
authored
Refactor validateRayServiceSpec (#2711)
Signed-off-by: hcc429 <[email protected]>
1 parent 05e9279 commit a7197c5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ray-operator/controllers/ray/rayservice_controller.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,13 @@ func validateRayServiceSpec(rayService *rayv1.RayService) error {
238238
if headSvc := rayService.Spec.RayClusterSpec.HeadGroupSpec.HeadService; headSvc != nil && headSvc.Name != "" {
239239
return fmt.Errorf("spec.rayClusterConfig.headGroupSpec.headService.metadata.name should not be set")
240240
}
241-
if rayService.Spec.UpgradeStrategy == nil {
242-
return nil
243-
}
244-
if upgradeType := rayService.Spec.UpgradeStrategy.Type; upgradeType != nil {
245-
if *upgradeType != rayv1.NewCluster && *upgradeType != rayv1.None {
246-
return fmt.Errorf("Spec.UpgradeStrategy.Type value %s is invalid, valid options are %s or %s", *upgradeType, rayv1.NewCluster, rayv1.None)
247-
}
241+
242+
// only NewCluster and None are valid upgradeType
243+
if rayService.Spec.UpgradeStrategy != nil &&
244+
rayService.Spec.UpgradeStrategy.Type != nil &&
245+
*rayService.Spec.UpgradeStrategy.Type != rayv1.None &&
246+
*rayService.Spec.UpgradeStrategy.Type != rayv1.NewCluster {
247+
return fmt.Errorf("Spec.UpgradeStrategy.Type value %s is invalid, valid options are %s or %s", *rayService.Spec.UpgradeStrategy.Type, rayv1.NewCluster, rayv1.None)
248248
}
249249
return nil
250250
}

0 commit comments

Comments
 (0)