Skip to content

Exit CFO initialisation if RayCluster CRD is not available #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/olm_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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://github.com/raw/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: |
Expand Down
27 changes: 15 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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
Expand Down