Skip to content

Commit

Permalink
raycluster_webhook.go initial unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianZaccaria committed May 10, 2024
1 parent 6c7cacb commit 258d3a4
Show file tree
Hide file tree
Showing 3 changed files with 662 additions and 24 deletions.
28 changes: 4 additions & 24 deletions pkg/controllers/raycluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,27 +100,7 @@ func (w *rayClusterWebhook) Default(ctx context.Context, obj runtime.Object) err
}

// WorkerGroupSpec
for i := range rayCluster.Spec.WorkerGroupSpecs {
workerSpec := &rayCluster.Spec.WorkerGroupSpecs[i]

// Append the list of environment variables for the worker container
for _, envVar := range envVarList() {
workerSpec.Template.Spec.Containers[0].Env = upsert(workerSpec.Template.Spec.Containers[0].Env, envVar, withEnvVarName(envVar.Name))
}

// Append the CA volumes
for _, caVol := range caVolumes(rayCluster) {
workerSpec.Template.Spec.Volumes = upsert(workerSpec.Template.Spec.Volumes, caVol, withVolumeName(caVol.Name))
}

// Append the certificate volume mounts
for _, mount := range certVolumeMounts() {
workerSpec.Template.Spec.Containers[0].VolumeMounts = upsert(workerSpec.Template.Spec.Containers[0].VolumeMounts, mount, byVolumeMountName)
}

// Append the create-cert Init Container
workerSpec.Template.Spec.InitContainers = upsert(workerSpec.Template.Spec.InitContainers, rayWorkerInitContainer(), withContainerName(initContainerName))
}
mutateWorkerGroupSpecs(rayCluster)
}

return nil
Expand Down Expand Up @@ -392,9 +372,9 @@ func validateWorkerInitContainer(rayCluster *rayv1.RayCluster) field.ErrorList {
for i := range rayCluster.Spec.WorkerGroupSpecs {
workerSpec := &rayCluster.Spec.WorkerGroupSpecs[i]
if err := contains(workerSpec.Template.Spec.InitContainers, rayWorkerInitContainer(), byContainerName,
field.NewPath("spec", "workerGroupSpecs", strconv.Itoa(i), "template", "spec", "initContainers"),
"create-cert Init Container is immutable"); err != nil {
allErrors = append(allErrors, err)
field.NewPath("spec", "workerGroupSpecs", strconv.Itoa(i), "template", "spec", "initContainers"),
"create-cert Init Container is immutable"); err != nil {
allErrors = append(allErrors, err)
}
}

Expand Down
Loading

0 comments on commit 258d3a4

Please sign in to comment.