-
Notifications
You must be signed in to change notification settings - Fork 59
add watches for owned resources and CRBs #526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add watches for owned resources and CRBs #526
Conversation
/hold |
7bca5c8
to
f1a8a13
Compare
@@ -220,7 +222,7 @@ func crbNameFromCluster(cluster *rayv1.RayCluster) string { | |||
func desiredOAuthClusterRoleBinding(cluster *rayv1.RayCluster) *rbacapply.ClusterRoleBindingApplyConfiguration { | |||
return rbacapply.ClusterRoleBinding( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really wonder, can this be a RoleBinding instead of a ClusterRoleBinding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I tried this a while back and it didn't work. I can give it another go though
afd3a10
to
d0eec5d
Compare
@@ -233,7 +237,7 @@ func crbNameFromCluster(cluster *rayv1.RayCluster) string { | |||
func desiredOAuthClusterRoleBinding(cluster *rayv1.RayCluster) *rbacapply.ClusterRoleBindingApplyConfiguration { | |||
return rbacapply.ClusterRoleBinding( | |||
crbNameFromCluster(cluster)). | |||
WithLabels(map[string]string{"ray.io/cluster-name": cluster.Name}). | |||
WithLabels(map[string]string{"ray.io/cluster-name": cluster.Name, "ray.io/cluster-namespace": cluster.Namespace}). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we scope the labels to ray.openshift.ai
instead of ray.io
that we do not own?
func(c context.Context, o client.Object) []reconcile.Request { | ||
return []reconcile.Request{{ | ||
NamespacedName: client.ObjectKey{ | ||
Name: o.GetLabels()["ray.io/cluster-name"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check for the absence of these labels? The watch will receive events for all CRBs. An alternative is to configure the cache to filter events only for our CRBs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it to check for the absence of the labels, I'm not sure how to configure the cache to filter for only our CRBs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created https://github.com/project-codeflare/codeflare-operator/tree/pr-cache-example that shows how to configure the manager cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Antonin, I'm adding this too so that it can be followed if someone finds this
https://github.com/kubernetes-sigs/controller-runtime/blob/main/designs/use-selectors-at-cache.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, this broke the AppWrapper controller. I submitted a fix here #640
a778eb8
to
7b1490e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just left a comment, otherwise LGTM. Great work!
pkg/controllers/support.go
Outdated
@@ -20,7 +20,7 @@ func serviceNameFromCluster(cluster *rayv1.RayCluster) string { | |||
|
|||
func desiredRayClientRoute(cluster *rayv1.RayCluster) *routeapply.RouteApplyConfiguration { | |||
return routeapply.Route(rayClientNameFromCluster(cluster), cluster.Namespace). | |||
WithLabels(map[string]string{"ray.io/cluster-name": cluster.Name}). | |||
WithLabels(map[string]string{"ray.openshift.ai/cluster-name": cluster.Name}). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should that be RayClusterNameLabel
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, did a find and replace in the controller code. Missed this one. Thanks for catching
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also added WithController to the OwnerReferences in support.go
/lgtm |
/lgtm |
6496d3f
to
bad723c
Compare
/unhold |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: astefanutti The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Kevin <[email protected]>
New changes are detected. LGTM label has been removed. |
/retest |
4673aeb
into
project-codeflare:main
Issue link
What changes have been made
I've added watches for owned resources so that the controller will automatically re-reconcile on updates to owned resources. I've also added a label to the CRB make mapping from CRB to RayCluster resource possible
Verification steps
Checks