Skip to content

Commit b9a258c

Browse files
committed
only use the applicationsNamespace in openshift
the codeflare operator checks for kuberay namespaces to apply network policies so it uses opendatahub DSCInitialization CRD which isn't available on vanilla k8s clusters so added a condition to check for DSCInitialization only when running on openshift This fixes the gatejobs running the codeflare-sdk repo as the e2e test jobs are failing because DSCInitialization isn't available on kind cluster that is being used for testing.
1 parent c03f1b5 commit b9a258c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

pkg/controllers/raycluster_controller.go

+12-9
Original file line numberDiff line numberDiff line change
@@ -269,18 +269,21 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
269269
// Locate the KubeRay operator deployment:
270270
// - First try to get the ODH / RHOAI application namespace from the DSCInitialization
271271
// - Or fallback to the well-known defaults
272+
// add check if running on openshift or vanilla kubernetes
272273
var kubeRayNamespaces []string
273-
dsci := &dsciv1.DSCInitialization{}
274-
err := r.Client.Get(ctx, client.ObjectKey{Name: "default-dsci"}, dsci)
275-
if errors.IsNotFound(err) {
276-
kubeRayNamespaces = []string{"opendatahub", "redhat-ods-applications"}
277-
} else if err != nil {
278-
return ctrl.Result{}, err
279-
} else {
280-
kubeRayNamespaces = []string{dsci.Spec.ApplicationsNamespace}
274+
kubeRayNamespaces = []string{"opendatahub", "redhat-ods-applications"}
275+
276+
if r.IsOpenShift {
277+
dsci := &dsciv1.DSCInitialization{}
278+
err := r.Client.Get(ctx, client.ObjectKey{Name: "default-dsci"}, dsci)
279+
if err != nil {
280+
return ctrl.Result{}, err
281+
} else {
282+
kubeRayNamespaces = []string{dsci.Spec.ApplicationsNamespace}
283+
}
281284
}
282285

283-
_, err = r.kubeClient.NetworkingV1().NetworkPolicies(cluster.Namespace).Apply(ctx, desiredHeadNetworkPolicy(cluster, r.Config, kubeRayNamespaces), metav1.ApplyOptions{FieldManager: controllerName, Force: true})
286+
_, err := r.kubeClient.NetworkingV1().NetworkPolicies(cluster.Namespace).Apply(ctx, desiredHeadNetworkPolicy(cluster, r.Config, kubeRayNamespaces), metav1.ApplyOptions{FieldManager: controllerName, Force: true})
284287
if err != nil {
285288
logger.Error(err, "Failed to update NetworkPolicy")
286289
}

0 commit comments

Comments
 (0)