Skip to content

Commit

Permalink
feat: validate the length of RayCluster name and worker group names
Browse files Browse the repository at this point in the history
Signed-off-by: Rueian <rueiancsie@gmail.com>
  • Loading branch information
rueian committed Feb 25, 2025
1 parent b24ba93 commit e6ee5ac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions ray-operator/controllers/ray/rayjob_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ var _ = Context("RayJob with different submission modes", func() {
Describe("RayJob with DeletionPolicy=DeleteCluster", Ordered, func() {
ctx := context.Background()
namespace := "default"
rayJob := rayJobTemplate("rayjob-test-deletionpolicy-deletecluster", namespace)
rayJob := rayJobTemplate("rayjob-test-deletionpolicy-1", namespace)
deletionPolicy := rayv1.DeleteClusterDeletionPolicy
rayJob.Spec.DeletionPolicy = &deletionPolicy
rayJob.Spec.ShutdownAfterJobFinishes = false
Expand Down Expand Up @@ -964,7 +964,7 @@ var _ = Context("RayJob with different submission modes", func() {
Describe("RayJob with DeletionPolicy=DeleteWorkers", Ordered, func() {
ctx := context.Background()
namespace := "default"
rayJob := rayJobTemplate("rayjob-test-deletionpolicy-deleteworkers", namespace)
rayJob := rayJobTemplate("rayjob-test-deletionpolicy-2", namespace)
deletionPolicy := rayv1.DeleteWorkersDeletionPolicy
rayJob.Spec.DeletionPolicy = &deletionPolicy
rayJob.Spec.ShutdownAfterJobFinishes = false
Expand Down Expand Up @@ -1213,7 +1213,7 @@ var _ = Context("RayJob with different submission modes", func() {
Describe("RayJob with DeletionPolicy=DeleteNone", Ordered, func() {
ctx := context.Background()
namespace := "default"
rayJob := rayJobTemplate("rayjob-test-deletionpolicy-deletenone", namespace)
rayJob := rayJobTemplate("rayjob-test-deletionpolicy-3", namespace)
deletionPolicy := rayv1.DeleteNoneDeletionPolicy
rayJob.Spec.DeletionPolicy = &deletionPolicy
rayJob.Spec.ShutdownAfterJobFinishes = false
Expand Down
4 changes: 2 additions & 2 deletions ray-operator/controllers/ray/utils/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ func ValidateRayClusterStatus(instance *rayv1.RayCluster) error {

// Validation for invalid Ray Cluster configurations.
func ValidateRayClusterSpec(instance *rayv1.RayCluster) error {
if len(instance.Name) > 63 {
if len(instance.Name) > 46 {
return fmt.Errorf("RayCluster name should be no more than 63 characters")
}
if len(instance.Spec.HeadGroupSpec.Template.Spec.Containers) == 0 {
return fmt.Errorf("headGroupSpec should have at least one container")
}

for _, workerGroup := range instance.Spec.WorkerGroupSpecs {
if len(workerGroup.GroupName) > 63 {
if len(workerGroup.GroupName) > 46 {
return fmt.Errorf("group name should be no more than 63 characters")
}
if len(workerGroup.Template.Spec.Containers) == 0 {
Expand Down
4 changes: 2 additions & 2 deletions ray-operator/controllers/ray/utils/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func TestValidateRayClusterSpecNames(t *testing.T) {
expectError bool
}{
{
name: "RayCluster name is too long (> 63 characters)",
name: "RayCluster name is too long (> 46 characters)",
rayCluster: &rayv1.RayCluster{
ObjectMeta: metav1.ObjectMeta{
Name: strings.Repeat("A", 64),
Expand All @@ -392,7 +392,7 @@ func TestValidateRayClusterSpecNames(t *testing.T) {
errorMessage: "RayCluster name should be no more than 63 characters",
},
{
name: "Worker group name is too long (> 63 characters)",
name: "Worker group name is too long (> 46 characters)",
rayCluster: &rayv1.RayCluster{
Spec: rayv1.RayClusterSpec{
HeadGroupSpec: rayv1.HeadGroupSpec{
Expand Down

0 comments on commit e6ee5ac

Please sign in to comment.