@@ -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,13 @@ 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
+ },
238
+ Spec : rayv1.RayClusterSpec {},
239
+ }
234
240
validRayCluster := & rayv1.RayCluster {
235
241
ObjectMeta : metav1.ObjectMeta {
236
242
Name : rayClusterName ,
@@ -253,7 +259,7 @@ func TestValidateCreate(t *testing.T) {
253
259
ValueFrom : & corev1.EnvVarSource {
254
260
SecretKeyRef : & corev1.SecretKeySelector {
255
261
LocalObjectReference : corev1.LocalObjectReference {
256
- Name : rayClusterName + "-oauth-config" ,
262
+ Name : oauthSecretNameFromCluster ( emptyRayCluster ) ,
257
263
},
258
264
Key : "cookie_secret" ,
259
265
},
@@ -263,7 +269,7 @@ func TestValidateCreate(t *testing.T) {
263
269
Args : []string {
264
270
"--https-address=:8443" ,
265
271
"--provider=openshift" ,
266
- "--openshift-service-account=" + rayClusterName + "-oauth-proxy" ,
272
+ "--openshift-service-account=" + oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
267
273
"--upstream=http://localhost:8265" ,
268
274
"--tls-cert=/etc/tls/private/tls.crt" ,
269
275
"--tls-key=/etc/tls/private/tls.key" ,
@@ -284,12 +290,12 @@ func TestValidateCreate(t *testing.T) {
284
290
Name : oauthProxyVolumeName ,
285
291
VolumeSource : corev1.VolumeSource {
286
292
Secret : & corev1.SecretVolumeSource {
287
- SecretName : rayClusterName + "-proxy-tls-secret" ,
293
+ SecretName : oauthServiceTLSSecretName ( emptyRayCluster ) ,
288
294
},
289
295
},
290
296
},
291
297
},
292
- ServiceAccountName : rayClusterName + "-oauth-proxy" ,
298
+ ServiceAccountName : oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
293
299
},
294
300
},
295
301
RayStartParams : map [string ]string {},
@@ -351,7 +357,15 @@ func TestValidateCreate(t *testing.T) {
351
357
352
358
func TestValidateUpdate (t * testing.T ) {
353
359
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"
355
369
validRayCluster := & rayv1.RayCluster {
356
370
ObjectMeta : metav1.ObjectMeta {
357
371
Name : rayClusterName ,
@@ -374,7 +388,7 @@ func TestValidateUpdate(t *testing.T) {
374
388
ValueFrom : & corev1.EnvVarSource {
375
389
SecretKeyRef : & corev1.SecretKeySelector {
376
390
LocalObjectReference : corev1.LocalObjectReference {
377
- Name : rayClusterName + "-oauth-config" ,
391
+ Name : oauthSecretNameFromCluster ( emptyRayCluster ) ,
378
392
},
379
393
Key : "cookie_secret" ,
380
394
},
@@ -396,7 +410,7 @@ func TestValidateUpdate(t *testing.T) {
396
410
Args : []string {
397
411
"--https-address=:8443" ,
398
412
"--provider=openshift" ,
399
- "--openshift-service-account=" + rayClusterName + "-oauth-proxy" ,
413
+ "--openshift-service-account=" + oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
400
414
"--upstream=http://localhost:8265" ,
401
415
"--tls-cert=/etc/tls/private/tls.crt" ,
402
416
"--tls-key=/etc/tls/private/tls.key" ,
@@ -419,7 +433,7 @@ func TestValidateUpdate(t *testing.T) {
419
433
Command : []string {
420
434
"sh" ,
421
435
"-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` ,
423
437
},
424
438
VolumeMounts : []corev1.VolumeMount {
425
439
{
@@ -440,15 +454,15 @@ func TestValidateUpdate(t *testing.T) {
440
454
Name : oauthProxyVolumeName ,
441
455
VolumeSource : corev1.VolumeSource {
442
456
Secret : & corev1.SecretVolumeSource {
443
- SecretName : rayClusterName + "-proxy-tls-secret" ,
457
+ SecretName : oauthServiceTLSSecretName ( emptyRayCluster ) ,
444
458
},
445
459
},
446
460
},
447
461
{
448
462
Name : "ca-vol" ,
449
463
VolumeSource : corev1.VolumeSource {
450
464
Secret : & corev1.SecretVolumeSource {
451
- SecretName : `ca-secret-` + rayClusterName ,
465
+ SecretName : caSecretNameFromCluster ( emptyRayCluster ) ,
452
466
},
453
467
},
454
468
},
@@ -459,7 +473,7 @@ func TestValidateUpdate(t *testing.T) {
459
473
},
460
474
},
461
475
},
462
- ServiceAccountName : rayClusterName + "-oauth-proxy" ,
476
+ ServiceAccountName : oauthServiceAccountNameFromCluster ( emptyRayCluster ) ,
463
477
},
464
478
},
465
479
RayStartParams : map [string ]string {},
@@ -505,7 +519,7 @@ func TestValidateUpdate(t *testing.T) {
505
519
Name : "ca-vol" ,
506
520
VolumeSource : corev1.VolumeSource {
507
521
Secret : & corev1.SecretVolumeSource {
508
- SecretName : `ca-secret-` + rayClusterName ,
522
+ SecretName : caSecretNameFromCluster ( emptyRayCluster ) ,
509
523
},
510
524
},
511
525
},
0 commit comments