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

feat(gc): Use SelfSubjectRulesReview to scan for garbage collectable resources #3326

Merged
merged 3 commits into from
Jun 2, 2022
Merged

Conversation

astefanutti
Copy link
Member

The GC trait currently scans all the resources based on the set of types returned by the Discovery API. This leads to a significant number of unauthorised requests, that have proved to overload the API server unnecessarily.

This PR improves the GC trait, to rely on SelfSubjectRulesReview requests, to scan for garbage collectable resources, assuming the operator can only garbage collect resources it has previously created.

Rate limiting is also added, so that one SelfSubjectRulesReview request is performed over a minute period at the maximum, allowing to refresh the cached set of collectable types, should the permissions granted to the operator service account changed at runtime.

Release Note

feat(gc): Use SelfSubjectRulesReview to scan for garbage collectable resources

@astefanutti astefanutti added the kind/feature New feature or request label Jun 1, 2022
Copy link
Contributor

@christophd christophd left a comment

Choose a reason for hiding this comment

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

Wow, awesome!


// Retrieve the permissions granted to the operator service account.
// We assume the operator has only to garbage collect the resources it has created.
srr := &authorization.SelfSubjectRulesReview{
Copy link
Member

@tadayosi tadayosi Jun 2, 2022

Choose a reason for hiding this comment

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

Just for confirmation, don't we need to also check it with OpenShift version of SSRR if it's on OpenShift? Is it redundant?
https://docs.openshift.com/container-platform/4.10/rest_api/authorization_apis/selfsubjectrulesreview-authorization-openshift-io-v1.html

Copy link
Member Author

Choose a reason for hiding this comment

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

Based on the testing I've done, authorization.k8s.io works also in OpenShift. Generally it seems vanilla k8s APIs are supported in OpenShift and somehow translated into their OpenShift counterpart if any.

@astefanutti
Copy link
Member Author

Let me merge this. The test failure in the OpenShift workflow is also present in main branch.

@astefanutti astefanutti merged commit 8a267fc into apache:main Jun 2, 2022
@astefanutti astefanutti deleted the pr-420 branch June 2, 2022 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants