@@ -27,6 +27,7 @@ import (
27
27
"strings"
28
28
29
29
"github.com/go-logr/logr"
30
+ "github.com/project-codeflare/codeflare-operator/pkg/config"
30
31
rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
31
32
32
33
corev1 "k8s.io/api/core/v1"
@@ -63,19 +64,19 @@ type RayClusterReconciler struct {
63
64
}
64
65
65
66
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"
74
74
)
75
75
76
76
var (
77
77
deletePolicy = metav1 .DeletePropagationForeground
78
78
deleteOptions = client.DeleteOptions {PropagationPolicy : & deletePolicy }
79
+ configInstance * config.CodeFlareOperatorConfiguration
79
80
)
80
81
81
82
// +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)
146
147
return ctrl.Result {}, nil
147
148
}
148
149
149
- if cluster .Status .State != "suspended" && annotationBoolVal ( logger , & cluster , oauthAnnotation ) && isOpenShift {
150
+ if cluster .Status .State != "suspended" && isRayDashboardOAuthEnabled ( ) && isOpenShift {
150
151
logger .Info ("Creating OAuth Objects" )
151
152
_ , err := r .routeClient .Routes (cluster .Namespace ).Apply (ctx , desiredClusterRoute (& cluster ), metav1.ApplyOptions {FieldManager : controllerName , Force : true })
152
153
if err != nil {
@@ -173,7 +174,7 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
173
174
logger .Error (err , "Failed to update OAuth ClusterRoleBinding" )
174
175
}
175
176
176
- } else if cluster .Status .State != "suspended" && ! annotationBoolVal ( logger , & cluster , oauthAnnotation ) && isOpenShift {
177
+ } else if cluster .Status .State != "suspended" && ! isRayDashboardOAuthEnabled ( ) && isOpenShift {
177
178
logger .Info ("Creating Dashboard Route" )
178
179
_ , err := r .routeClient .Routes (cluster .Namespace ).Apply (ctx , createRoute (& cluster ), metav1.ApplyOptions {FieldManager : controllerName , Force : true })
179
180
if err != nil {
@@ -188,7 +189,7 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
188
189
}
189
190
return ctrl.Result {}, nil
190
191
191
- } else if cluster .Status .State != "suspended" && ! annotationBoolVal ( logger , & cluster , oauthAnnotation ) && ! isOpenShift {
192
+ } else if cluster .Status .State != "suspended" && ! isRayDashboardOAuthEnabled ( ) && ! isOpenShift {
192
193
logger .Info ("Creating Dashboard Ingress" )
193
194
_ , err := r .kubeClient .NetworkingV1 ().Ingresses (cluster .Namespace ).Apply (ctx , createIngressApplyConfiguration (& cluster , ingressHost ), metav1.ApplyOptions {FieldManager : controllerName , Force : true })
194
195
if err != nil {
@@ -360,7 +361,7 @@ func createRoute(cluster *rayv1.RayCluster) *routeapply.RouteApplyConfiguration
360
361
WithLabels (map [string ]string {"ray.io/cluster-name" : cluster .Name }).
361
362
WithSpec (routeapply .RouteSpec ().
362
363
WithTo (routeapply .RouteTargetReference ().WithKind ("Service" ).WithName (serviceNameFromCluster (cluster ))).
363
- WithPort (routeapply .RoutePort ().WithTargetPort (intstr .FromString (RegularServicePortName ))).
364
+ WithPort (routeapply .RoutePort ().WithTargetPort (intstr .FromString (regularServicePortName ))).
364
365
WithTLS (routeapply .TLSConfig ().
365
366
WithTermination ("edge" )),
366
367
).
@@ -442,7 +443,7 @@ func createIngressApplyConfiguration(cluster *rayv1.RayCluster, ingressHost stri
442
443
WithService (networkingv1ac .IngressServiceBackend ().
443
444
WithName (serviceNameFromCluster (cluster )).
444
445
WithPort (networkingv1ac .ServiceBackendPort ().
445
- WithName (RegularServicePortName ),
446
+ WithName (regularServicePortName ),
446
447
),
447
448
),
448
449
),
@@ -510,5 +511,9 @@ func getClusterType(logger logr.Logger, clientset *kubernetes.Clientset, cluster
510
511
}
511
512
}
512
513
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