@@ -25,7 +25,9 @@ import (
2525 gomega "github.com/onsi/gomega"
2626 rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
2727
28- v1 "k8s.io/api/core/v1"
28+ corev1 "k8s.io/api/core/v1"
29+ apierrors "k8s.io/apimachinery/pkg/api/errors"
30+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2931
3032 "github.com/opendatahub-io/distributed-workloads/tests/common/support"
3133)
@@ -58,7 +60,7 @@ func getNotebookCommand(rayImage string) []string {
5860 }
5961}
6062
61- func GetDashboardUrl (test support.Test , namespace * v1 .Namespace , rayCluster * rayv1.RayCluster ) string {
63+ func GetDashboardUrl (test support.Test , namespace * corev1 .Namespace , rayCluster * rayv1.RayCluster ) string {
6264 dashboardName := "ray-dashboard-" + rayCluster .Name
6365 route := support .GetRoute (test , namespace .Name , dashboardName )
6466 hostname := route .Status .Ingress [0 ].Host
@@ -79,6 +81,18 @@ func GetTestJobId(test support.Test, rayClient support.RayClusterClient) string
7981 return jobID
8082}
8183
84+ // EnsureNotebookServiceAccount ensures the Notebook ServiceAccount exists in the target namespace.
85+ // This avoids webhook/controller failures when creating the Notebook CR.
86+ func ensureNotebookServiceAccount (test support.Test , namespace string ) {
87+ test .T ().Helper ()
88+ saName := "jupyter-nb-kube-3aadmin"
89+ sa := & corev1.ServiceAccount {ObjectMeta : metav1.ObjectMeta {Name : saName , Namespace : namespace }}
90+ _ , err := test .Client ().Core ().CoreV1 ().ServiceAccounts (namespace ).Create (test .Ctx (), sa , metav1.CreateOptions {})
91+ if err != nil && ! apierrors .IsAlreadyExists (err ) {
92+ test .T ().Fatalf ("Failed to create ServiceAccount %s/%s: %v" , namespace , saName , err )
93+ }
94+ }
95+
8296// Adds a unique suffix to the provided string
8397func uniqueSuffix (prefix string ) string {
8498 suffix := gonanoid .MustGenerate ("1234567890abcdef" , 4 )
0 commit comments