diff --git a/pkg/controllers/raycluster_webhook.go b/pkg/controllers/raycluster_webhook.go index 584e9af86..ba13bcad6 100644 --- a/pkg/controllers/raycluster_webhook.go +++ b/pkg/controllers/raycluster_webhook.go @@ -90,7 +90,7 @@ func (w *rayClusterWebhook) Default(ctx context.Context, obj runtime.Object) err } // Append the create-cert Init Container - rayCluster.Spec.HeadGroupSpec.Template.Spec.InitContainers = upsert(rayCluster.Spec.HeadGroupSpec.Template.Spec.InitContainers, w.rayHeadInitContainer(rayCluster), withContainerName(initContainerName)) + rayCluster.Spec.HeadGroupSpec.Template.Spec.InitContainers = upsert(rayCluster.Spec.HeadGroupSpec.Template.Spec.InitContainers, rayHeadInitContainer(rayCluster, w), withContainerName(initContainerName)) // Append the CA volumes for _, caVol := range caVolumes(rayCluster) { @@ -144,7 +144,7 @@ func (w *rayClusterWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj r allErrors = append(allErrors, validateOAuthProxyVolume(rayCluster)...) allErrors = append(allErrors, validateHeadGroupServiceAccountName(rayCluster)...) // Init Container related errors - allErrors = append(allErrors, w.validateHeadInitContainer(rayCluster)...) + allErrors = append(allErrors, validateHeadInitContainer(rayCluster, w)...) allErrors = append(allErrors, validateWorkerInitContainer(rayCluster)...) allErrors = append(allErrors, validateHeadEnvVars(rayCluster)...) allErrors = append(allErrors, validateWorkerEnvVars(rayCluster)...) @@ -325,7 +325,7 @@ func caVolumes(rayCluster *rayv1.RayCluster) []corev1.Volume { return caVolumes } -func (w *rayClusterWebhook) rayHeadInitContainer(rayCluster *rayv1.RayCluster) corev1.Container { +func rayHeadInitContainer(rayCluster *rayv1.RayCluster, w *rayClusterWebhook) corev1.Container { rayClientRoute := "rayclient-" + rayCluster.Name + "-" + rayCluster.Namespace + "." + w.Config.IngressDomain // Service name for basic interactive svcDomain := rayCluster.Name + "-head-svc." + rayCluster.Namespace + ".svc" @@ -357,10 +357,10 @@ func rayWorkerInitContainer() corev1.Container { return initContainerWorker } -func (w *rayClusterWebhook) validateHeadInitContainer(rayCluster *rayv1.RayCluster) field.ErrorList { +func validateHeadInitContainer(rayCluster *rayv1.RayCluster, w *rayClusterWebhook) field.ErrorList { var allErrors field.ErrorList - if err := contains(rayCluster.Spec.HeadGroupSpec.Template.Spec.InitContainers, w.rayHeadInitContainer(rayCluster), byContainerName, + if err := contains(rayCluster.Spec.HeadGroupSpec.Template.Spec.InitContainers, rayHeadInitContainer(rayCluster, w), byContainerName, field.NewPath("spec", "headGroupSpec", "template", "spec", "initContainers"), "create-cert Init Container is immutable"); err != nil { allErrors = append(allErrors, err)