Skip to content
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

Skip creator owner RBAC step if noCreatorRBAC annotation is present #47259

Merged
merged 6 commits into from
Oct 4, 2024

Conversation

JonCrowther
Copy link
Contributor

@JonCrowther JonCrowther commented Sep 25, 2024

Issue: #45591

Requires webhook changes: rancher/webhook#511

Problem

When a service account creates a cluster, the project handler and cluster handler both attempt to create ClusterOwner and ProjectOwner roles and bind those roles to the service account. The problem is that we don't support those roles for service accounts, so the logs get flooded with errors as it keeps retrying to add those roles.

Solution

To avoid the errors and the re-queuing, we have added a new annotation field.cattle.io/no-creator-rbac. If that annotation exists when a cluster is created, it is propagated to the project and neither ProjectOwner or ClusterOwner roles get created. That way users can specify when they want this automated process to occur.

Testing

The issue has steps to recreate the problem with turtles. Alternatively, you can:

  • create a cluster in the UI
  • copy the cluster.provisioning.cattle.io CRD and the config CRD (in my case it was digitaloceanconfig.rke-machine-config.cattle.io)
  • delete the cluster
  • create a service account and give it cluster admin clusterrole
  • create a kubeconfig for the service account
  • apply the copied CRDs using the service account's kubeconfig
  • See the errors in the logs

After applying the changes in this PR and the webhook PR, you can add the annotation field.cattle.io/no-creator-rbac to the cluster CRD and see that the errors don't appear in the logs on creation.

Engineering Testing

Manual Testing

As mentioned, creating an annotated cluster with a service account yields no errors.

Automated Testing

  • Test types added/modified:
    • Unit

Summary:

  • test that cluster annotation gets propagated to created projects
  • test that ClusterOwner role doesn't get added if annotation exists
  • test that ProjectOwner role doesn't get added if annotation exists

QA Testing Considerations

Regressions Considerations

TODO

Existing / newly added automated tests that provide evidence there are no regressions:

  • TODO

@JonCrowther JonCrowther self-assigned this Sep 25, 2024
raulcabello
raulcabello previously approved these changes Sep 30, 2024
pmatseykanets
pmatseykanets previously approved these changes Sep 30, 2024
crobby
crobby previously approved these changes Sep 30, 2024
Copy link
Contributor

@crobby crobby left a comment

Choose a reason for hiding this comment

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

looks good

crobby
crobby previously approved these changes Oct 1, 2024
pmatseykanets
pmatseykanets previously approved these changes Oct 1, 2024
Copy link
Contributor

@pmatseykanets pmatseykanets left a comment

Choose a reason for hiding this comment

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

@JonCrowther JonCrowther merged commit 2a7abe9 into rancher:main Oct 4, 2024
12 checks passed
@JonCrowther JonCrowther deleted the no-creator-rbac-annotation branch October 4, 2024 14:17
rohitsakala pushed a commit to rohitsakala/rancher that referenced this pull request Oct 31, 2024
…ancher#47259)

* Skip creator RBAC step if annotation is present

* Add tests

* Move annotation check outside of CreatorMadeOwner condition

* Rename annotation

* Add debug log for when we skip creating owner RBAC

* Increase log level from debug to info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants