diff --git a/pkg/controllers/raycluster_webhook.go b/pkg/controllers/raycluster_webhook.go index a07e04a1f..1933f80ba 100644 --- a/pkg/controllers/raycluster_webhook.go +++ b/pkg/controllers/raycluster_webhook.go @@ -110,7 +110,7 @@ func (w *rayClusterWebhook) Default(ctx context.Context, obj runtime.Object) err rayCluster.Spec.WorkerGroupSpecs[0].Template.Spec.Volumes = upsert(rayCluster.Spec.WorkerGroupSpecs[0].Template.Spec.Volumes, caVol, withVolumeName(caVol.Name)) } // Append the create-cert Init Container - rayCluster.Spec.WorkerGroupSpecs[0].Template.Spec.InitContainers = upsert(rayCluster.Spec.WorkerGroupSpecs[0].Template.Spec.InitContainers, rayWorkerInitContainer(rayCluster), withContainerName(initContainerName)) + rayCluster.Spec.WorkerGroupSpecs[0].Template.Spec.InitContainers = upsert(rayCluster.Spec.WorkerGroupSpecs[0].Template.Spec.InitContainers, rayWorkerInitContainer(), withContainerName(initContainerName)) } @@ -143,7 +143,11 @@ func (w *rayClusterWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj r allErrors = append(allErrors, validateOAuthProxyContainer(rayCluster)...) allErrors = append(allErrors, validateOAuthProxyVolume(rayCluster)...) allErrors = append(allErrors, validateHeadGroupServiceAccountName(rayCluster)...) - + // Init Container related errors + allErrors = append(allErrors, w.validateHeadInitContainer(rayCluster)...) + allErrors = append(allErrors, w.validateWorkerInitContainer(rayCluster)...) + allErrors = append(allErrors, validateEnvVars(rayCluster)...) + allErrors = append(allErrors, validateCaVolumes(rayCluster)...) return warnings, allErrors.ToAggregate() } @@ -338,7 +342,7 @@ func (w *rayClusterWebhook) rayHeadInitContainer(rayCluster *rayv1.RayCluster) c return initContainerHead } -func rayWorkerInitContainer(rayCluster *rayv1.RayCluster) corev1.Container { +func rayWorkerInitContainer() corev1.Container { initContainerWorker := corev1.Container{ Name: "create-cert", Image: "quay.io/project-codeflare/ray:latest-py39-cu118", @@ -367,7 +371,7 @@ func (w *rayClusterWebhook) validateHeadInitContainer(rayCluster *rayv1.RayClust func (w *rayClusterWebhook) validateWorkerInitContainer(rayCluster *rayv1.RayCluster) field.ErrorList { var allErrors field.ErrorList - if err := contains(rayCluster.Spec.WorkerGroupSpecs[0].Template.Spec.InitContainers, rayWorkerInitContainer(rayCluster), byContainerName, + if err := contains(rayCluster.Spec.WorkerGroupSpecs[0].Template.Spec.InitContainers, rayWorkerInitContainer(), byContainerName, field.NewPath("spec", "workerGroupSpecs", "0", "template", "spec", "initContainers"), "create-cert Init Container is immutable"); err != nil { allErrors = append(allErrors, err)