Skip to content

Commit f36c3ec

Browse files
Always run RayCluster Controller
1 parent 04b6c63 commit f36c3ec

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func main() {
184184
}
185185

186186
v, err := HasAPIResourceForGVK(kubeClient.DiscoveryClient, rayv1.GroupVersion.WithKind("RayCluster"))
187-
if v && *cfg.KubeRay.RayDashboardOAuthEnabled {
187+
if v {
188188
rayClusterController := controllers.RayClusterReconciler{Client: mgr.GetClient(), Scheme: mgr.GetScheme()}
189189
exitOnError(rayClusterController.SetupWithManager(mgr), "Error setting up RayCluster controller")
190190
} else if err != nil {

pkg/controllers/raycluster_controller.go

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"strings"
2828

2929
"github.com/go-logr/logr"
30+
"github.com/project-codeflare/codeflare-operator/pkg/config"
3031
rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
3132

3233
corev1 "k8s.io/api/core/v1"
@@ -63,19 +64,19 @@ type RayClusterReconciler struct {
6364
}
6465

6566
const (
66-
requeueTime = 10
67-
controllerName = "codeflare-raycluster-controller"
68-
oAuthFinalizer = "ray.openshift.ai/oauth-finalizer"
69-
oAuthServicePort = 443
70-
oAuthServicePortName = "oauth-proxy"
71-
oauthAnnotation = "codeflare.dev/oauth"
72-
RegularServicePortName = "dashboard"
73-
logRequeueing = "requeueing"
67+
requeueTime = 10
68+
controllerName = "codeflare-raycluster-controller"
69+
oAuthFinalizer = "ray.openshift.ai/oauth-finalizer"
70+
oAuthServicePort = 443
71+
oAuthServicePortName = "oauth-proxy"
72+
regularServicePortName = "dashboard"
73+
logRequeueing = "requeueing"
7474
)
7575

7676
var (
7777
deletePolicy = metav1.DeletePropagationForeground
7878
deleteOptions = client.DeleteOptions{PropagationPolicy: &deletePolicy}
79+
configInstance *config.CodeFlareOperatorConfiguration
7980
)
8081

8182
// +kubebuilder:rbac:groups=ray.io,resources=rayclusters,verbs=get;list;watch;create;update;patch;delete
@@ -146,7 +147,7 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
146147
return ctrl.Result{}, nil
147148
}
148149

149-
if cluster.Status.State != "suspended" && annotationBoolVal(logger, &cluster, oauthAnnotation) && isOpenShift {
150+
if cluster.Status.State != "suspended" && isRayDashboardOAuthEnabled() && isOpenShift {
150151
logger.Info("Creating OAuth Objects")
151152
_, err := r.routeClient.Routes(cluster.Namespace).Apply(ctx, desiredClusterRoute(&cluster), metav1.ApplyOptions{FieldManager: controllerName, Force: true})
152153
if err != nil {
@@ -173,7 +174,7 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
173174
logger.Error(err, "Failed to update OAuth ClusterRoleBinding")
174175
}
175176

176-
} else if cluster.Status.State != "suspended" && !annotationBoolVal(logger, &cluster, oauthAnnotation) && isOpenShift {
177+
} else if cluster.Status.State != "suspended" && !isRayDashboardOAuthEnabled() && isOpenShift {
177178
logger.Info("Creating Dashboard Route")
178179
_, err := r.routeClient.Routes(cluster.Namespace).Apply(ctx, createRoute(&cluster), metav1.ApplyOptions{FieldManager: controllerName, Force: true})
179180
if err != nil {
@@ -188,7 +189,7 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
188189
}
189190
return ctrl.Result{}, nil
190191

191-
} else if cluster.Status.State != "suspended" && !annotationBoolVal(logger, &cluster, oauthAnnotation) && !isOpenShift {
192+
} else if cluster.Status.State != "suspended" && !isRayDashboardOAuthEnabled() && !isOpenShift {
192193
logger.Info("Creating Dashboard Ingress")
193194
_, err := r.kubeClient.NetworkingV1().Ingresses(cluster.Namespace).Apply(ctx, createIngressApplyConfiguration(&cluster, ingressHost), metav1.ApplyOptions{FieldManager: controllerName, Force: true})
194195
if err != nil {
@@ -360,7 +361,7 @@ func createRoute(cluster *rayv1.RayCluster) *routeapply.RouteApplyConfiguration
360361
WithLabels(map[string]string{"ray.io/cluster-name": cluster.Name}).
361362
WithSpec(routeapply.RouteSpec().
362363
WithTo(routeapply.RouteTargetReference().WithKind("Service").WithName(serviceNameFromCluster(cluster))).
363-
WithPort(routeapply.RoutePort().WithTargetPort(intstr.FromString(RegularServicePortName))).
364+
WithPort(routeapply.RoutePort().WithTargetPort(intstr.FromString(regularServicePortName))).
364365
WithTLS(routeapply.TLSConfig().
365366
WithTermination("edge")),
366367
).
@@ -442,7 +443,7 @@ func createIngressApplyConfiguration(cluster *rayv1.RayCluster, ingressHost stri
442443
WithService(networkingv1ac.IngressServiceBackend().
443444
WithName(serviceNameFromCluster(cluster)).
444445
WithPort(networkingv1ac.ServiceBackendPort().
445-
WithName(RegularServicePortName),
446+
WithName(regularServicePortName),
446447
),
447448
),
448449
),
@@ -510,5 +511,9 @@ func getClusterType(logger logr.Logger, clientset *kubernetes.Clientset, cluster
510511
}
511512
}
512513

513-
// No more ingress_options - Removing completely.
514-
// What to do about ingress_domain? Needed for local_interactive?
514+
func isRayDashboardOAuthEnabled() bool {
515+
if configInstance.KubeRay != nil && configInstance.KubeRay.RayDashboardOAuthEnabled != nil {
516+
return *configInstance.KubeRay.RayDashboardOAuthEnabled
517+
}
518+
return true
519+
}

0 commit comments

Comments
 (0)