From 7b250c8e1f224b3bd134943d883400068ef42f8a Mon Sep 17 00:00:00 2001 From: ChristianZaccaria Date: Thu, 18 Apr 2024 15:40:48 +0100 Subject: [PATCH 1/2] Adjust olm_tests workflow to create raycluster CRD for deployment --- .github/workflows/olm_tests.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/olm_tests.yaml b/.github/workflows/olm_tests.yaml index abce29d3d..cfb8f66b7 100644 --- a/.github/workflows/olm_tests.yaml +++ b/.github/workflows/olm_tests.yaml @@ -72,6 +72,13 @@ jobs: kubectl create namespace openshift-operators kubectl create -f .github/resources-olm-upgrade/operatorgroup.yaml + - name: Install Required KubeRay CRDs for Pod Initialisation + run: | + kubectl create -f https://raw.githubusercontent.com/ray-project/kuberay/v1.1.0/ray-operator/config/crd/bases/ray.io_rayclusters.yaml + # wait for a while to be sure CRDs are installed + sleep 1 + kubectl wait --for=condition=Established crd/rayclusters.ray.io --timeout=60s + - name: Deploy latest released CodeFlare operator from OLM id: deploy run: | From 8035a3bafddaeec6f00cb886bf507cc104f8933d Mon Sep 17 00:00:00 2001 From: ChristianZaccaria Date: Thu, 18 Apr 2024 16:40:14 +0100 Subject: [PATCH 2/2] Refactor CRD check to exit if RayCluster CRD not available --- main.go | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index 700f12e8f..fde3db708 100644 --- a/main.go +++ b/main.go @@ -128,8 +128,16 @@ func main() { kubeClient, err := kubernetes.NewForConfig(kubeConfig) exitOnError(err, "unable to create Kubernetes client") - namespace := namespaceOrDie() + // Checking for RayCluster CRD availability to ensure the RayCluster Controller can initialise. + ok, err := hasAPIResourceForGVK(kubeClient.DiscoveryClient, rayv1.GroupVersion.WithKind("RayCluster")) + if err != nil { + exitOnError(err, "Could not determine if RayCluster CR is present on cluster.") + } + if !ok { + exitOnError(fmt.Errorf("RayCluster CRD is not available on the cluster"), "Required CRD not available.") + } + namespace := namespaceOrDie() exitOnError(loadIntoOrCreate(ctx, kubeClient, namespace, configMapName, cfg), "unable to initialise configuration") kubeConfig.Burst = int(ptr.Deref(cfg.ClientConnection.Burst, int32(rest.DefaultBurst))) @@ -171,18 +179,13 @@ func setupControllers(mgr ctrl.Manager, dc discovery.DiscoveryInterface, cfg *co exitOnError(controllers.SetupRayClusterWebhookWithManager(mgr, cfg.KubeRay), "error setting up RayCluster webhook") - ok, err := hasAPIResourceForGVK(dc, rayv1.GroupVersion.WithKind("RayCluster")) - if ok { - rayClusterController := controllers.RayClusterReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - Config: cfg.KubeRay, - IsOpenShift: isOpenShift, - } - exitOnError(rayClusterController.SetupWithManager(mgr), "Error setting up RayCluster controller") - } else if err != nil { - exitOnError(err, "Could not determine if RayCluster CR present on cluster.") + rayClusterController := controllers.RayClusterReconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Config: cfg.KubeRay, + IsOpenShift: isOpenShift, } + exitOnError(rayClusterController.SetupWithManager(mgr), "Error setting up RayCluster controller") } // +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;update