Skip to content

Commit 2f100af

Browse files
Scope RayCluster finalizer into ray.openshift.ai
1 parent 5e5f5b3 commit 2f100af

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

pkg/controllers/raycluster_controller.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,26 @@ type RayClusterReconciler struct {
5353
}
5454

5555
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"
6262
)
6363

6464
var (
6565
deletePolicy = metav1.DeletePropagationForeground
6666
deleteOptions = client.DeleteOptions{PropagationPolicy: &deletePolicy}
6767
)
6868

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
7676

7777
// Reconcile is part of the main kubernetes reconciliation loop which aims to
7878
// 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)
9797
}
9898

9999
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)
103103
if err := r.Update(ctx, &cluster); err != nil {
104104
// this log is info level since errors are not fatal and are expected
105105
logger.Info("WARN: Failed to update RayCluster with finalizer", "error", err.Error(), logRequeueing, true)
106106
return ctrl.Result{RequeueAfter: requeueTime}, err
107107
}
108108
}
109-
} else if controllerutil.ContainsFinalizer(&cluster, CodeflareOAuthFinalizer) {
109+
} else if controllerutil.ContainsFinalizer(&cluster, oAuthFinalizer) {
110110
err := client.IgnoreNotFound(r.Client.Delete(
111111
ctx,
112112
&rbacv1.ClusterRoleBinding{
@@ -120,7 +120,7 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
120120
logger.Error(err, "Failed to remove OAuth ClusterRoleBinding.", logRequeueing, true)
121121
return ctrl.Result{RequeueAfter: requeueTime}, err
122122
}
123-
controllerutil.RemoveFinalizer(&cluster, CodeflareOAuthFinalizer)
123+
controllerutil.RemoveFinalizer(&cluster, oAuthFinalizer)
124124
if err := r.Update(ctx, &cluster); err != nil {
125125
logger.Error(err, "Failed to remove finalizer from RayCluster", logRequeueing, true)
126126
return ctrl.Result{RequeueAfter: requeueTime}, err
@@ -208,7 +208,7 @@ func desiredClusterRoute(cluster *rayv1.RayCluster) *routeapply.RouteApplyConfig
208208
WithLabels(map[string]string{"ray.io/cluster-name": cluster.Name}).
209209
WithSpec(routeapply.RouteSpec().
210210
WithTo(routeapply.RouteTargetReference().WithKind("Service").WithName(oauthServiceNameFromCluster(cluster))).
211-
WithPort(routeapply.RoutePort().WithTargetPort(intstr.FromString((OAuthServicePortName)))).
211+
WithPort(routeapply.RoutePort().WithTargetPort(intstr.FromString((oAuthServicePortName)))).
212212
WithTLS(routeapply.TLSConfig().
213213
WithInsecureEdgeTerminationPolicy(routev1.InsecureEdgeTerminationPolicyRedirect).
214214
WithTermination(routev1.TLSTerminationReencrypt),
@@ -235,9 +235,9 @@ func desiredOAuthService(cluster *rayv1.RayCluster) *coreapply.ServiceApplyConfi
235235
coreapply.ServiceSpec().
236236
WithPorts(
237237
coreapply.ServicePort().
238-
WithName(OAuthServicePortName).
239-
WithPort(OAuthServicePort).
240-
WithTargetPort(intstr.FromString(OAuthServicePortName)).
238+
WithName(oAuthServicePortName).
239+
WithPort(oAuthServicePort).
240+
WithTargetPort(intstr.FromString(oAuthServicePortName)).
241241
WithProtocol(corev1.ProtocolTCP),
242242
).
243243
WithSelector(map[string]string{"ray.io/cluster": cluster.Name, "ray.io/node-type": "head"}),

pkg/controllers/raycluster_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ var _ = Describe("RayCluster controller", func() {
121121
Eventually(func() bool {
122122
err := k8sClient.Get(ctx, typeNamespaceName, &foundRayCluster)
123123
Expect(err).To(Not(HaveOccurred()))
124-
return stringInList(foundRayCluster.Finalizers, CodeflareOAuthFinalizer)
124+
return stringInList(foundRayCluster.Finalizers, oAuthFinalizer)
125125
}, SpecTimeout(time.Second*10)).Should(Equal(true))
126126
})
127127

0 commit comments

Comments
 (0)