Skip to content

RHOAIENG-22373: Fix incorrect default of RHOAI/ODH installation #675

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
wants to merge 1 commit into from
Closed
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
36 changes: 25 additions & 11 deletions pkg/controllers/raycluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,21 +266,35 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
}
}

// Locate the KubeRay operator deployment:
// - First try to get the ODH / RHOAI application namespace from the DSCInitialization
// - Or fallback to the well-known defaults
var kubeRayNamespaces []string
dsci := &dsciv1.DSCInitialization{}
err := r.Client.Get(ctx, client.ObjectKey{Name: "default-dsci"}, dsci)
if errors.IsNotFound(err) {
kubeRayNamespaces = []string{"opendatahub", "redhat-ods-applications"}
} else if err != nil {
return ctrl.Result{}, err
if r.IsOpenShift {
// Locate the KubeRay operator deployment:
// - First try to get the ODH / RHOAI application namespace from the DSCInitialization
// - Or fallback to the well-known defaults
dsci := &dsciv1.DSCInitialization{}

// TODO it wont find the dsci if it is named something else (which is entirely possible) - find it some other way
err := r.Client.Get(ctx, client.ObjectKey{Name: "default-dsci"}, dsci)
if err != nil {
return ctrl.Result{}, err
} else {
kubeRayNamespaces = []string{dsci.Spec.ApplicationsNamespace}
}
} else {
kubeRayNamespaces = []string{dsci.Spec.ApplicationsNamespace}
var pods corev1.PodList
err := r.Client.List(ctx, &pods,
client.MatchingLabels{"app.kubernetes.io/name": "kuberay"},
)
if err != nil {
return ctrl.Result{}, err
}

for _, pod := range pods.Items {
kubeRayNamespaces = []string{pod.Namespace}
}
}

_, err = r.kubeClient.NetworkingV1().NetworkPolicies(cluster.Namespace).Apply(ctx, desiredHeadNetworkPolicy(cluster, r.Config, kubeRayNamespaces), metav1.ApplyOptions{FieldManager: controllerName, Force: true})
_, err := r.kubeClient.NetworkingV1().NetworkPolicies(cluster.Namespace).Apply(ctx, desiredHeadNetworkPolicy(cluster, r.Config, kubeRayNamespaces), metav1.ApplyOptions{FieldManager: controllerName, Force: true})
if err != nil {
logger.Error(err, "Failed to update NetworkPolicy")
}
Expand Down
Loading