Skip to content

Commit

Permalink
Refactor validateRayServiceSpec (#2711)
Browse files Browse the repository at this point in the history
Signed-off-by: hcc429 <[email protected]>
  • Loading branch information
hcc429 authored Jan 4, 2025
1 parent 05e9279 commit a7197c5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ray-operator/controllers/ray/rayservice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ func validateRayServiceSpec(rayService *rayv1.RayService) error {
if headSvc := rayService.Spec.RayClusterSpec.HeadGroupSpec.HeadService; headSvc != nil && headSvc.Name != "" {
return fmt.Errorf("spec.rayClusterConfig.headGroupSpec.headService.metadata.name should not be set")
}
if rayService.Spec.UpgradeStrategy == nil {
return nil
}
if upgradeType := rayService.Spec.UpgradeStrategy.Type; upgradeType != nil {
if *upgradeType != rayv1.NewCluster && *upgradeType != rayv1.None {
return fmt.Errorf("Spec.UpgradeStrategy.Type value %s is invalid, valid options are %s or %s", *upgradeType, rayv1.NewCluster, rayv1.None)
}

// only NewCluster and None are valid upgradeType
if rayService.Spec.UpgradeStrategy != nil &&
rayService.Spec.UpgradeStrategy.Type != nil &&
*rayService.Spec.UpgradeStrategy.Type != rayv1.None &&
*rayService.Spec.UpgradeStrategy.Type != rayv1.NewCluster {
return fmt.Errorf("Spec.UpgradeStrategy.Type value %s is invalid, valid options are %s or %s", *rayService.Spec.UpgradeStrategy.Type, rayv1.NewCluster, rayv1.None)
}
return nil
}
Expand Down

0 comments on commit a7197c5

Please sign in to comment.