@@ -124,7 +124,7 @@ func TestRayClusterWebhookDefault(t *testing.T) {
124
124
125
125
t .Run ("Expected required service account name for the head group" , func (t * testing.T ) {
126
126
test .Expect (validRayCluster .Spec .HeadGroupSpec .Template .Spec .ServiceAccountName ).
127
- To (Equal (validRayCluster . Name + "-oauth-proxy" ),
127
+ To (Equal (oauthServiceAccountNameFromCluster ( validRayCluster ) ),
128
128
"Expected the service account name to be set correctly" )
129
129
})
130
130
@@ -230,7 +230,16 @@ func TestRayClusterWebhookDefault(t *testing.T) {
230
230
231
231
func TestValidateCreate (t * testing.T ) {
232
232
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
+ }
234
243
validRayCluster := & rayv1.RayCluster {
235
244
ObjectMeta : metav1.ObjectMeta {
236
245
Name : rayClusterName ,
@@ -253,7 +262,7 @@ func TestValidateCreate(t *testing.T) {
253
262
ValueFrom : & corev1.EnvVarSource {
254
263
SecretKeyRef : & corev1.SecretKeySelector {
255
264
LocalObjectReference : corev1.LocalObjectReference {
256
- Name : rayClusterName + "-oauth-config" ,
265
+ Name : oauthSecretNameFromCluster ( emptyRayCluster ) ,
257
266
},
258
267
Key : "cookie_secret" ,
259
268
},
@@ -263,7 +272,7 @@ func TestValidateCreate(t *testing.T) {
263
272
Args : []string {
264
273
"--https-address=:8443" ,
265
274
"--provider=openshift" ,
266
- "--openshift-service-account=" + rayClusterName + "-oauth-proxy" ,
275
+ "--openshift-service-account=" + oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
267
276
"--upstream=http://localhost:8265" ,
268
277
"--tls-cert=/etc/tls/private/tls.crt" ,
269
278
"--tls-key=/etc/tls/private/tls.key" ,
@@ -284,12 +293,12 @@ func TestValidateCreate(t *testing.T) {
284
293
Name : oauthProxyVolumeName ,
285
294
VolumeSource : corev1.VolumeSource {
286
295
Secret : & corev1.SecretVolumeSource {
287
- SecretName : rayClusterName + "-proxy-tls-secret" ,
296
+ SecretName : oauthServiceTLSSecretName ( emptyRayCluster ) ,
288
297
},
289
298
},
290
299
},
291
300
},
292
- ServiceAccountName : rayClusterName + "-oauth-proxy" ,
301
+ ServiceAccountName : oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
293
302
},
294
303
},
295
304
RayStartParams : map [string ]string {},
@@ -351,7 +360,18 @@ func TestValidateCreate(t *testing.T) {
351
360
352
361
func TestValidateUpdate (t * testing.T ) {
353
362
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"
355
375
validRayCluster := & rayv1.RayCluster {
356
376
ObjectMeta : metav1.ObjectMeta {
357
377
Name : rayClusterName ,
@@ -374,7 +394,7 @@ func TestValidateUpdate(t *testing.T) {
374
394
ValueFrom : & corev1.EnvVarSource {
375
395
SecretKeyRef : & corev1.SecretKeySelector {
376
396
LocalObjectReference : corev1.LocalObjectReference {
377
- Name : rayClusterName + "-oauth-config" ,
397
+ Name : oauthSecretNameFromCluster ( emptyRayCluster ) ,
378
398
},
379
399
Key : "cookie_secret" ,
380
400
},
@@ -396,7 +416,7 @@ func TestValidateUpdate(t *testing.T) {
396
416
Args : []string {
397
417
"--https-address=:8443" ,
398
418
"--provider=openshift" ,
399
- "--openshift-service-account=" + rayClusterName + "-oauth-proxy" ,
419
+ "--openshift-service-account=" + oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
400
420
"--upstream=http://localhost:8265" ,
401
421
"--tls-cert=/etc/tls/private/tls.crt" ,
402
422
"--tls-key=/etc/tls/private/tls.key" ,
@@ -419,7 +439,7 @@ func TestValidateUpdate(t *testing.T) {
419
439
Command : []string {
420
440
"sh" ,
421
441
"-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` ,
423
443
},
424
444
VolumeMounts : []corev1.VolumeMount {
425
445
{
@@ -440,15 +460,15 @@ func TestValidateUpdate(t *testing.T) {
440
460
Name : oauthProxyVolumeName ,
441
461
VolumeSource : corev1.VolumeSource {
442
462
Secret : & corev1.SecretVolumeSource {
443
- SecretName : rayClusterName + "-proxy-tls-secret" ,
463
+ SecretName : oauthServiceTLSSecretName ( emptyRayCluster ) ,
444
464
},
445
465
},
446
466
},
447
467
{
448
468
Name : "ca-vol" ,
449
469
VolumeSource : corev1.VolumeSource {
450
470
Secret : & corev1.SecretVolumeSource {
451
- SecretName : `ca-secret-` + rayClusterName ,
471
+ SecretName : caSecretNameFromCluster ( emptyRayCluster ) ,
452
472
},
453
473
},
454
474
},
@@ -459,7 +479,7 @@ func TestValidateUpdate(t *testing.T) {
459
479
},
460
480
},
461
481
},
462
- ServiceAccountName : rayClusterName + "-oauth-proxy" ,
482
+ ServiceAccountName : oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
463
483
},
464
484
},
465
485
RayStartParams : map [string ]string {},
@@ -505,7 +525,7 @@ func TestValidateUpdate(t *testing.T) {
505
525
Name : "ca-vol" ,
506
526
VolumeSource : corev1.VolumeSource {
507
527
Secret : & corev1.SecretVolumeSource {
508
- SecretName : `ca-secret-` + rayClusterName ,
528
+ SecretName : caSecretNameFromCluster ( emptyRayCluster ) ,
509
529
},
510
530
},
511
531
},
0 commit comments