@@ -53,26 +53,26 @@ type RayClusterReconciler struct {
53
53
}
54
54
55
55
const (
56
- requeueTime = 10
57
- controllerName = "codeflare-raycluster-controller"
58
- CodeflareOAuthFinalizer = "openshift.ai/oauth-finalizer"
59
- OAuthServicePort = 443
60
- OAuthServicePortName = "oauth-proxy"
61
- logRequeueing = "requeueing"
56
+ requeueTime = 10
57
+ controllerName = "codeflare-raycluster-controller"
58
+ oAuthFinalizer = "ray. openshift.ai/oauth-finalizer"
59
+ oAuthServicePort = 443
60
+ oAuthServicePortName = "oauth-proxy"
61
+ logRequeueing = "requeueing"
62
62
)
63
63
64
64
var (
65
65
deletePolicy = metav1 .DeletePropagationForeground
66
66
deleteOptions = client.DeleteOptions {PropagationPolicy : & deletePolicy }
67
67
)
68
68
69
- //+kubebuilder:rbac:groups=ray.io,resources=rayclusters,verbs=get;list;watch;create;update;patch;delete
70
- //+kubebuilder:rbac:groups=ray.io,resources=rayclusters/status,verbs=get;update;patch
71
- //+kubebuilder:rbac:groups=ray.io,resources=rayclusters/finalizers,verbs=update
72
- //+kubebuilder:rbac:groups=route.openshift.io,resources=routes,verbs=patch;delete;get
73
- //+kubebuilder:rbac:groups=core,resources=secrets,verbs=get;create;patch;delete;get
74
- //+kubebuilder:rbac:groups=core,resources=services,verbs=patch;delete;get
75
- //+kubebuilder:rbac:groups=core,resources=serviceaccounts,verbs=patch;delete;get
69
+ // +kubebuilder:rbac:groups=ray.io,resources=rayclusters,verbs=get;list;watch;create;update;patch;delete
70
+ // +kubebuilder:rbac:groups=ray.io,resources=rayclusters/status,verbs=get;update;patch
71
+ // +kubebuilder:rbac:groups=ray.io,resources=rayclusters/finalizers,verbs=update
72
+ // +kubebuilder:rbac:groups=route.openshift.io,resources=routes,verbs=patch;delete;get
73
+ // +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;create;patch;delete;get
74
+ // +kubebuilder:rbac:groups=core,resources=services,verbs=patch;delete;get
75
+ // +kubebuilder:rbac:groups=core,resources=serviceaccounts,verbs=patch;delete;get
76
76
77
77
// Reconcile is part of the main kubernetes reconciliation loop which aims to
78
78
// move the current state of the cluster closer to the desired state.
@@ -97,16 +97,16 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
97
97
}
98
98
99
99
if cluster .ObjectMeta .DeletionTimestamp .IsZero () {
100
- if ! controllerutil .ContainsFinalizer (& cluster , CodeflareOAuthFinalizer ) {
101
- logger .Info ("Add a finalizer" , "finalizer" , CodeflareOAuthFinalizer )
102
- controllerutil .AddFinalizer (& cluster , CodeflareOAuthFinalizer )
100
+ if ! controllerutil .ContainsFinalizer (& cluster , oAuthFinalizer ) {
101
+ logger .Info ("Add a finalizer" , "finalizer" , oAuthFinalizer )
102
+ controllerutil .AddFinalizer (& cluster , oAuthFinalizer )
103
103
if err := r .Update (ctx , & cluster ); err != nil {
104
104
// this log is info level since errors are not fatal and are expected
105
105
logger .Info ("WARN: Failed to update RayCluster with finalizer" , "error" , err .Error (), logRequeueing , true )
106
106
return ctrl.Result {RequeueAfter : requeueTime }, err
107
107
}
108
108
}
109
- } else if controllerutil .ContainsFinalizer (& cluster , CodeflareOAuthFinalizer ) {
109
+ } else if controllerutil .ContainsFinalizer (& cluster , oAuthFinalizer ) {
110
110
err := client .IgnoreNotFound (r .Client .Delete (
111
111
ctx ,
112
112
& rbacv1.ClusterRoleBinding {
@@ -120,7 +120,7 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
120
120
logger .Error (err , "Failed to remove OAuth ClusterRoleBinding." , logRequeueing , true )
121
121
return ctrl.Result {RequeueAfter : requeueTime }, err
122
122
}
123
- controllerutil .RemoveFinalizer (& cluster , CodeflareOAuthFinalizer )
123
+ controllerutil .RemoveFinalizer (& cluster , oAuthFinalizer )
124
124
if err := r .Update (ctx , & cluster ); err != nil {
125
125
logger .Error (err , "Failed to remove finalizer from RayCluster" , logRequeueing , true )
126
126
return ctrl.Result {RequeueAfter : requeueTime }, err
@@ -208,7 +208,7 @@ func desiredClusterRoute(cluster *rayv1.RayCluster) *routeapply.RouteApplyConfig
208
208
WithLabels (map [string ]string {"ray.io/cluster-name" : cluster .Name }).
209
209
WithSpec (routeapply .RouteSpec ().
210
210
WithTo (routeapply .RouteTargetReference ().WithKind ("Service" ).WithName (oauthServiceNameFromCluster (cluster ))).
211
- WithPort (routeapply .RoutePort ().WithTargetPort (intstr .FromString ((OAuthServicePortName )))).
211
+ WithPort (routeapply .RoutePort ().WithTargetPort (intstr .FromString ((oAuthServicePortName )))).
212
212
WithTLS (routeapply .TLSConfig ().
213
213
WithInsecureEdgeTerminationPolicy (routev1 .InsecureEdgeTerminationPolicyRedirect ).
214
214
WithTermination (routev1 .TLSTerminationReencrypt ),
@@ -235,9 +235,9 @@ func desiredOAuthService(cluster *rayv1.RayCluster) *coreapply.ServiceApplyConfi
235
235
coreapply .ServiceSpec ().
236
236
WithPorts (
237
237
coreapply .ServicePort ().
238
- WithName (OAuthServicePortName ).
239
- WithPort (OAuthServicePort ).
240
- WithTargetPort (intstr .FromString (OAuthServicePortName )).
238
+ WithName (oAuthServicePortName ).
239
+ WithPort (oAuthServicePort ).
240
+ WithTargetPort (intstr .FromString (oAuthServicePortName )).
241
241
WithProtocol (corev1 .ProtocolTCP ),
242
242
).
243
243
WithSelector (map [string ]string {"ray.io/cluster" : cluster .Name , "ray.io/node-type" : "head" }),
0 commit comments