diff --git a/pkg/controllers/raycluster_controller.go b/pkg/controllers/raycluster_controller.go index 55bd34657..02c1a307d 100644 --- a/pkg/controllers/raycluster_controller.go +++ b/pkg/controllers/raycluster_controller.go @@ -193,7 +193,7 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) } } - if cluster.Status.State != "suspended" && isRayDashboardOAuthEnabled(r.Config) && r.IsOpenShift { + if !isRayClusterSuspended(cluster) && isRayDashboardOAuthEnabled(r.Config) && r.IsOpenShift { logger.Info("Creating OAuth Objects") _, err := r.routeClient.Routes(cluster.Namespace).Apply(ctx, desiredClusterRoute(cluster), metav1.ApplyOptions{FieldManager: controllerName, Force: true}) if err != nil { @@ -239,7 +239,7 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) return ctrl.Result{RequeueAfter: requeueTime}, err } - } else if cluster.Status.State != "suspended" && !isRayDashboardOAuthEnabled(r.Config) && !r.IsOpenShift { + } else if !isRayClusterSuspended(cluster) && !isRayDashboardOAuthEnabled(r.Config) && !r.IsOpenShift { logger.Info("We detected being on Vanilla Kubernetes!") logger.Info("Creating Dashboard Ingress") dashboardName := dashboardNameFromCluster(cluster) @@ -312,6 +312,10 @@ func isMTLSEnabled(cfg *config.KubeRayConfiguration) bool { return cfg == nil || ptr.Deref(cfg.MTLSEnabled, true) } +func isRayClusterSuspended(cluster *rayv1.RayCluster) bool { + return cluster.Spec.Suspend != nil && ptr.Deref(cluster.Spec.Suspend, false) +} + func crbNameFromCluster(cluster *rayv1.RayCluster) string { if shouldUseOldName(cluster) { return cluster.Name + "-" + cluster.Namespace + "-auth" diff --git a/pkg/controllers/raycluster_controller_test.go b/pkg/controllers/raycluster_controller_test.go index db49adf98..c3769c5a9 100644 --- a/pkg/controllers/raycluster_controller_test.go +++ b/pkg/controllers/raycluster_controller_test.go @@ -21,6 +21,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/project-codeflare/codeflare-common/support" rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1" corev1 "k8s.io/api/core/v1" @@ -65,6 +66,7 @@ var _ = Describe("RayCluster controller", func() { }, RayStartParams: map[string]string{}, }, + Suspend: support.Ptr(false), }, } _, err = rayClient.RayV1().RayClusters(namespace.Name).Create(ctx, raycluster, metav1.CreateOptions{}) @@ -209,6 +211,7 @@ var _ = Describe("RayCluster controller", func() { }, RayStartParams: map[string]string{}, }, + Suspend: support.Ptr(false), }, } _, err := rayClient.RayV1().RayClusters(namespaceName).Create(ctx, rayclusterWithPullSecret, metav1.CreateOptions{})