@@ -124,7 +124,7 @@ func TestRayClusterWebhookDefault(t *testing.T) {
124124
125125 t .Run ("Expected required service account name for the head group" , func (t * testing.T ) {
126126 test .Expect (validRayCluster .Spec .HeadGroupSpec .Template .Spec .ServiceAccountName ).
127- To (Equal (validRayCluster . Name + "-oauth-proxy" ),
127+ To (Equal (oauthServiceAccountNameFromCluster ( validRayCluster ) ),
128128 "Expected the service account name to be set correctly" )
129129 })
130130
@@ -230,7 +230,13 @@ func TestRayClusterWebhookDefault(t *testing.T) {
230230
231231func TestValidateCreate (t * testing.T ) {
232232 test := support .NewTest (t )
233-
233+ emptyRayCluster := & rayv1.RayCluster {
234+ ObjectMeta : metav1.ObjectMeta {
235+ Name : rayClusterName ,
236+ Namespace : namespace ,
237+ },
238+ Spec : rayv1.RayClusterSpec {},
239+ }
234240 validRayCluster := & rayv1.RayCluster {
235241 ObjectMeta : metav1.ObjectMeta {
236242 Name : rayClusterName ,
@@ -253,7 +259,7 @@ func TestValidateCreate(t *testing.T) {
253259 ValueFrom : & corev1.EnvVarSource {
254260 SecretKeyRef : & corev1.SecretKeySelector {
255261 LocalObjectReference : corev1.LocalObjectReference {
256- Name : rayClusterName + "-oauth-config" ,
262+ Name : oauthSecretNameFromCluster ( emptyRayCluster ) ,
257263 },
258264 Key : "cookie_secret" ,
259265 },
@@ -263,7 +269,7 @@ func TestValidateCreate(t *testing.T) {
263269 Args : []string {
264270 "--https-address=:8443" ,
265271 "--provider=openshift" ,
266- "--openshift-service-account=" + rayClusterName + "-oauth-proxy" ,
272+ "--openshift-service-account=" + oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
267273 "--upstream=http://localhost:8265" ,
268274 "--tls-cert=/etc/tls/private/tls.crt" ,
269275 "--tls-key=/etc/tls/private/tls.key" ,
@@ -284,12 +290,12 @@ func TestValidateCreate(t *testing.T) {
284290 Name : oauthProxyVolumeName ,
285291 VolumeSource : corev1.VolumeSource {
286292 Secret : & corev1.SecretVolumeSource {
287- SecretName : rayClusterName + "-proxy-tls-secret" ,
293+ SecretName : oauthServiceTLSSecretName ( emptyRayCluster ) ,
288294 },
289295 },
290296 },
291297 },
292- ServiceAccountName : rayClusterName + "-oauth-proxy" ,
298+ ServiceAccountName : oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
293299 },
294300 },
295301 RayStartParams : map [string ]string {},
@@ -351,7 +357,15 @@ func TestValidateCreate(t *testing.T) {
351357
352358func TestValidateUpdate (t * testing.T ) {
353359 test := support .NewTest (t )
354-
360+ emptyRayCluster := & rayv1.RayCluster {
361+ ObjectMeta : metav1.ObjectMeta {
362+ Name : rayClusterName ,
363+ Namespace : namespace ,
364+ },
365+ Spec : rayv1.RayClusterSpec {},
366+ }
367+ rayClientRoute := rayClientNameFromCluster (emptyRayCluster ) + "-" + emptyRayCluster .Namespace + "." + rcWebhook .Config .IngressDomain
368+ svcDomain := serviceNameFromCluster (emptyRayCluster ) + "." + emptyRayCluster .Namespace + ".svc"
355369 validRayCluster := & rayv1.RayCluster {
356370 ObjectMeta : metav1.ObjectMeta {
357371 Name : rayClusterName ,
@@ -374,7 +388,7 @@ func TestValidateUpdate(t *testing.T) {
374388 ValueFrom : & corev1.EnvVarSource {
375389 SecretKeyRef : & corev1.SecretKeySelector {
376390 LocalObjectReference : corev1.LocalObjectReference {
377- Name : rayClusterName + "-oauth-config" ,
391+ Name : oauthSecretNameFromCluster ( emptyRayCluster ) ,
378392 },
379393 Key : "cookie_secret" ,
380394 },
@@ -396,7 +410,7 @@ func TestValidateUpdate(t *testing.T) {
396410 Args : []string {
397411 "--https-address=:8443" ,
398412 "--provider=openshift" ,
399- "--openshift-service-account=" + rayClusterName + "-oauth-proxy" ,
413+ "--openshift-service-account=" + oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
400414 "--upstream=http://localhost:8265" ,
401415 "--tls-cert=/etc/tls/private/tls.crt" ,
402416 "--tls-key=/etc/tls/private/tls.key" ,
@@ -419,7 +433,7 @@ func TestValidateUpdate(t *testing.T) {
419433 Command : []string {
420434 "sh" ,
421435 "-c" ,
422- `cd /home/ray/workspace/tls && openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr -subj '/CN=ray-head' && printf "authorityKeyIdentifier=keyid,issuer\nbasicConstraints=CA:FALSE\nsubjectAltName = @alt_names\n[alt_names]\nDNS.1 = 127.0.0.1\nDNS.2 = localhost\nDNS.3 = ${FQ_RAY_IP}\nDNS.4 = $(awk 'END{print $1}' /etc/hosts)\nDNS.5 = rayclient- ` + rayClusterName + `-` + namespace + `. \nDNS.6 = ` + rayClusterName + `-head-svc.` + namespace + `.svc` + `">./domain.ext && cp /home/ray/workspace/ca/* . && openssl x509 -req -CA ca.crt -CAkey ca.key -in server.csr -out server.crt -days 365 -CAcreateserial -extfile domain.ext` ,
436+ `cd /home/ray/workspace/tls && openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr -subj '/CN=ray-head' && printf "authorityKeyIdentifier=keyid,issuer\nbasicConstraints=CA:FALSE\nsubjectAltName = @alt_names\n[alt_names]\nDNS.1 = 127.0.0.1\nDNS.2 = localhost\nDNS.3 = ${FQ_RAY_IP}\nDNS.4 = $(awk 'END{print $1}' /etc/hosts)\nDNS.5 = ` + rayClientRoute + `\nDNS.6 = ` + svcDomain + `">./domain.ext && cp /home/ray/workspace/ca/* . && openssl x509 -req -CA ca.crt -CAkey ca.key -in server.csr -out server.crt -days 365 -CAcreateserial -extfile domain.ext` ,
423437 },
424438 VolumeMounts : []corev1.VolumeMount {
425439 {
@@ -440,15 +454,15 @@ func TestValidateUpdate(t *testing.T) {
440454 Name : oauthProxyVolumeName ,
441455 VolumeSource : corev1.VolumeSource {
442456 Secret : & corev1.SecretVolumeSource {
443- SecretName : rayClusterName + "-proxy-tls-secret" ,
457+ SecretName : oauthServiceTLSSecretName ( emptyRayCluster ) ,
444458 },
445459 },
446460 },
447461 {
448462 Name : "ca-vol" ,
449463 VolumeSource : corev1.VolumeSource {
450464 Secret : & corev1.SecretVolumeSource {
451- SecretName : `ca-secret-` + rayClusterName ,
465+ SecretName : caSecretNameFromCluster ( emptyRayCluster ) ,
452466 },
453467 },
454468 },
@@ -459,7 +473,7 @@ func TestValidateUpdate(t *testing.T) {
459473 },
460474 },
461475 },
462- ServiceAccountName : rayClusterName + "-oauth-proxy" ,
476+ ServiceAccountName : oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
463477 },
464478 },
465479 RayStartParams : map [string ]string {},
@@ -505,7 +519,7 @@ func TestValidateUpdate(t *testing.T) {
505519 Name : "ca-vol" ,
506520 VolumeSource : corev1.VolumeSource {
507521 Secret : & corev1.SecretVolumeSource {
508- SecretName : `ca-secret-` + rayClusterName ,
522+ SecretName : caSecretNameFromCluster ( emptyRayCluster ) ,
509523 },
510524 },
511525 },
0 commit comments