Skip to content

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

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

KPostOffice
Copy link
Collaborator

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

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • Testing is not required for this change

Sorry, something went wrong.

@KPostOffice
Copy link
Collaborator Author

/hold
Need to test

@@ -220,7 +222,7 @@ func crbNameFromCluster(cluster *rayv1.RayCluster) string {
func desiredOAuthClusterRoleBinding(cluster *rayv1.RayCluster) *rbacapply.ClusterRoleBindingApplyConfiguration {
return rbacapply.ClusterRoleBinding(
Copy link
Contributor

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?

Copy link
Collaborator Author

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

@KPostOffice KPostOffice force-pushed the watch4owned branch 2 times, most recently from afd3a10 to d0eec5d Compare April 17, 2024 20:32
@@ -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}).
Copy link
Contributor

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"],
Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Collaborator

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

Copy link
Contributor

@astefanutti astefanutti left a 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!

@@ -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}).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that be RayClusterNameLabel?

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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

@astefanutti
Copy link
Contributor

/lgtm

@astefanutti
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jun 28, 2024
@openshift-ci openshift-ci bot removed the lgtm label Jun 28, 2024
@KPostOffice KPostOffice force-pushed the watch4owned branch 3 times, most recently from 6496d3f to bad723c Compare June 28, 2024 17:23
@KPostOffice
Copy link
Collaborator Author

/unhold

@astefanutti
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jun 28, 2024
@astefanutti
Copy link
Contributor

/approve

Copy link

openshift-ci bot commented Jun 28, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Signed-off-by: Kevin <[email protected]>
Copy link

openshift-ci bot commented Jun 28, 2024

New changes are detected. LGTM label has been removed.

@KPostOffice
Copy link
Collaborator Author

/retest

@openshift-merge-bot openshift-merge-bot bot merged commit 4673aeb into project-codeflare:main Jun 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants