@@ -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,16 @@ 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+ Annotations : map [string ]string {
238+ newNameAnnotation : "true" ,
239+ },
240+ },
241+ Spec : rayv1.RayClusterSpec {},
242+ }
234243 validRayCluster := & rayv1.RayCluster {
235244 ObjectMeta : metav1.ObjectMeta {
236245 Name : rayClusterName ,
@@ -253,7 +262,7 @@ func TestValidateCreate(t *testing.T) {
253262 ValueFrom : & corev1.EnvVarSource {
254263 SecretKeyRef : & corev1.SecretKeySelector {
255264 LocalObjectReference : corev1.LocalObjectReference {
256- Name : rayClusterName + "-oauth-config" ,
265+ Name : oauthSecretNameFromCluster ( emptyRayCluster ) ,
257266 },
258267 Key : "cookie_secret" ,
259268 },
@@ -263,7 +272,7 @@ func TestValidateCreate(t *testing.T) {
263272 Args : []string {
264273 "--https-address=:8443" ,
265274 "--provider=openshift" ,
266- "--openshift-service-account=" + rayClusterName + "-oauth-proxy" ,
275+ "--openshift-service-account=" + oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
267276 "--upstream=http://localhost:8265" ,
268277 "--tls-cert=/etc/tls/private/tls.crt" ,
269278 "--tls-key=/etc/tls/private/tls.key" ,
@@ -284,12 +293,12 @@ func TestValidateCreate(t *testing.T) {
284293 Name : oauthProxyVolumeName ,
285294 VolumeSource : corev1.VolumeSource {
286295 Secret : & corev1.SecretVolumeSource {
287- SecretName : rayClusterName + "-proxy-tls-secret" ,
296+ SecretName : oauthServiceTLSSecretName ( emptyRayCluster ) ,
288297 },
289298 },
290299 },
291300 },
292- ServiceAccountName : rayClusterName + "-oauth-proxy" ,
301+ ServiceAccountName : oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
293302 },
294303 },
295304 RayStartParams : map [string ]string {},
@@ -351,7 +360,18 @@ func TestValidateCreate(t *testing.T) {
351360
352361func TestValidateUpdate (t * testing.T ) {
353362 test := support .NewTest (t )
354-
363+ emptyRayCluster := & rayv1.RayCluster {
364+ ObjectMeta : metav1.ObjectMeta {
365+ Name : rayClusterName ,
366+ Namespace : namespace ,
367+ Annotations : map [string ]string {
368+ newNameAnnotation : "true" ,
369+ },
370+ },
371+ Spec : rayv1.RayClusterSpec {},
372+ }
373+ rayClientRoute := rayClientNameFromCluster (emptyRayCluster ) + "-" + emptyRayCluster .Namespace + "." + rcWebhook .Config .IngressDomain
374+ svcDomain := serviceNameFromCluster (emptyRayCluster ) + "." + emptyRayCluster .Namespace + ".svc"
355375 validRayCluster := & rayv1.RayCluster {
356376 ObjectMeta : metav1.ObjectMeta {
357377 Name : rayClusterName ,
@@ -374,7 +394,7 @@ func TestValidateUpdate(t *testing.T) {
374394 ValueFrom : & corev1.EnvVarSource {
375395 SecretKeyRef : & corev1.SecretKeySelector {
376396 LocalObjectReference : corev1.LocalObjectReference {
377- Name : rayClusterName + "-oauth-config" ,
397+ Name : oauthSecretNameFromCluster ( emptyRayCluster ) ,
378398 },
379399 Key : "cookie_secret" ,
380400 },
@@ -396,7 +416,7 @@ func TestValidateUpdate(t *testing.T) {
396416 Args : []string {
397417 "--https-address=:8443" ,
398418 "--provider=openshift" ,
399- "--openshift-service-account=" + rayClusterName + "-oauth-proxy" ,
419+ "--openshift-service-account=" + oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
400420 "--upstream=http://localhost:8265" ,
401421 "--tls-cert=/etc/tls/private/tls.crt" ,
402422 "--tls-key=/etc/tls/private/tls.key" ,
@@ -419,7 +439,7 @@ func TestValidateUpdate(t *testing.T) {
419439 Command : []string {
420440 "sh" ,
421441 "-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` ,
442+ `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` ,
423443 },
424444 VolumeMounts : []corev1.VolumeMount {
425445 {
@@ -440,15 +460,15 @@ func TestValidateUpdate(t *testing.T) {
440460 Name : oauthProxyVolumeName ,
441461 VolumeSource : corev1.VolumeSource {
442462 Secret : & corev1.SecretVolumeSource {
443- SecretName : rayClusterName + "-proxy-tls-secret" ,
463+ SecretName : oauthServiceTLSSecretName ( emptyRayCluster ) ,
444464 },
445465 },
446466 },
447467 {
448468 Name : "ca-vol" ,
449469 VolumeSource : corev1.VolumeSource {
450470 Secret : & corev1.SecretVolumeSource {
451- SecretName : `ca-secret-` + rayClusterName ,
471+ SecretName : caSecretNameFromCluster ( emptyRayCluster ) ,
452472 },
453473 },
454474 },
@@ -459,7 +479,7 @@ func TestValidateUpdate(t *testing.T) {
459479 },
460480 },
461481 },
462- ServiceAccountName : rayClusterName + "-oauth-proxy" ,
482+ ServiceAccountName : oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
463483 },
464484 },
465485 RayStartParams : map [string ]string {},
@@ -505,7 +525,7 @@ func TestValidateUpdate(t *testing.T) {
505525 Name : "ca-vol" ,
506526 VolumeSource : corev1.VolumeSource {
507527 Secret : & corev1.SecretVolumeSource {
508- SecretName : `ca-secret-` + rayClusterName ,
528+ SecretName : caSecretNameFromCluster ( emptyRayCluster ) ,
509529 },
510530 },
511531 },
0 commit comments