✨ Make RBACPreAuthorizer collection verbs configurable#2539
✨ Make RBACPreAuthorizer collection verbs configurable#2539perdasilva wants to merge 1 commit intooperator-framework:mainfrom
Conversation
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR decouples RBACPreAuthorizer from component-specific cluster-scoped permission requirements by making clusterCollectionVerbs configurable via a functional option, allowing different appliers to request different RBAC checks.
Changes:
- Added
WithClusterCollectionVerbs(...)option and plumbed configurable cluster-scoped collection verbs through pre-authorization attribute generation. - Updated unit tests to construct the pre-authorizer with explicit
list/watchcluster collection verbs. - Configured the helm reconciler’s pre-authorizer to include cluster-scoped
list/watchchecks.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/operator-controller/authorization/rbac.go | Introduces functional option + stores cluster collection verbs on the pre-authorizer; passes verbs into attribute generation. |
| internal/operator-controller/authorization/rbac_test.go | Updates pre-authorizer construction to include configured cluster collection verbs. |
| cmd/operator-controller/main.go | Configures helm reconciler to require cluster-scoped list/watch checks. |
Comments suppressed due to low confidence (1)
internal/operator-controller/authorization/rbac.go:342
- This capacity estimate comment is now stale: it says
len(clusterCollectionVerbs) records (2), butclusterCollectionVerbsis configurable and may be 0 or any other length. Update the comment to avoid hardcoding2(or clarify it as an example for list/watch).
// Calculate initial capacity as an upper-bound estimate:
// - For each key: len(objectVerbs) records (4)
// - For unique namespaces: len(namespacedCollectionVerbs) records (1 per unique namespace across all keys in a GVR)
// We use totalKeys as upper bound (worst case: each key in different namespace)
// - For each GVR: len(clusterCollectionVerbs) records (2)
totalKeys := 0
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
64b4642 to
4935449
Compare
4935449 to
e833a37
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
internal/operator-controller/authorization/rbac.go:342
- The capacity-estimation comment still hardcodes "(2)" cluster-scoped records per GVR, but
clusterCollectionVerbsis now configurable. Update the comment to avoid implying a fixed count (e.g., remove "(2)" or describe it generically).
// Calculate initial capacity as an upper-bound estimate:
// - For each key: len(objectVerbs) records (4)
// - For unique namespaces: len(namespacedCollectionVerbs) records (1 per unique namespace across all keys in a GVR)
// We use totalKeys as upper bound (worst case: each key in different namespace)
// - For each GVR: len(clusterCollectionVerbs) records (2)
totalKeys := 0
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2539 +/- ##
==========================================
+ Coverage 64.25% 68.61% +4.36%
==========================================
Files 131 131
Lines 9288 9301 +13
==========================================
+ Hits 5968 6382 +414
+ Misses 2849 2435 -414
- Partials 471 484 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/hold updating e2es |
6e181ec to
fc6d891
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
internal/operator-controller/authorization/rbac.go:342
- The capacity-estimation comment says "len(clusterCollectionVerbs) records (2)", but
clusterCollectionVerbsis now configurable and may be 0 or any length. Update the comment to avoid implying a fixed value (or remove the parenthetical).
// Calculate initial capacity as an upper-bound estimate:
// - For each key: len(objectVerbs) records (4)
// - For unique namespaces: len(namespacedCollectionVerbs) records (1 per unique namespace across all keys in a GVR)
// We use totalKeys as upper bound (worst case: each key in different namespace)
// - For each GVR: len(clusterCollectionVerbs) records (2)
totalKeys := 0
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fc6d891 to
3007b27
Compare
3007b27 to
f8509ea
Compare
|
New changes are detected. LGTM label has been removed. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
f8509ea to
458224b
Compare
458224b to
267ee0b
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
267ee0b to
48014ec
Compare
48014ec to
d754558
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
internal/operator-controller/authorization/rbac.go:349
- The capacity-estimation comment hardcodes assumptions that no longer hold now that collection verbs are configurable (e.g., it says len(clusterCollectionVerbs) records "(2)"). Update the comment to describe this generically so it stays correct when callers configure different verb counts.
// Calculate initial capacity as an upper-bound estimate:
// - For each key: len(objectVerbs) records (4)
// - For unique namespaces: len(namespacedCollectionVerbs) records (1 per unique namespace across all keys in a GVR)
// We use totalKeys as upper bound (worst case: each key in different namespace)
// - For each GVR: len(clusterCollectionVerbs) records (2)
totalKeys := 0
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d754558 to
16b6b38
Compare
16b6b38 to
1d7a64a
Compare
1d7a64a to
9d66382
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
internal/operator-controller/authorization/rbac.go:349
- The capacity-estimation comment hardcodes "(2)" cluster collection verb records, but
clusterCollectionVerbsis now configurable and can be 0..N. Update the comment to avoid implying a fixed size (or derive it directly fromlen(clusterCollectionVerbs)).
// Calculate initial capacity as an upper-bound estimate:
// - For each key: len(objectVerbs) records (4)
// - For unique namespaces: len(namespacedCollectionVerbs) records (1 per unique namespace across all keys in a GVR)
// We use totalKeys as upper bound (worst case: each key in different namespace)
// - For each GVR: len(clusterCollectionVerbs) records (2)
totalKeys := 0
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
internal/operator-controller/rukpak/render/registryv1/generators/generators.go
Outdated
Show resolved
Hide resolved
|
/unhold |
Make both clusterCollectionVerbs and namespacedCollectionVerbs on RBACPreAuthorizer configurable via functional options, decoupling them from the hardcoded verbs that were tightly coupled to the contentmanager's requirements. Both the helm and boxcutter appliers explicitly configure namespacedCollectionVerbs with "create". The helm applier additionally configures clusterCollectionVerbs with "list" and "watch" (needed by contentmanager), while the boxcutter applier uses no cluster collection verbs. Also updates e2e tests to select the appropriate RBAC template based on the BoxcutterRuntime feature gate, using a narrower template without list/watch when BoxcutterRuntime is enabled. Closes: operator-framework#1911 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Per G. da Silva <[email protected]>
9d66382 to
6b23a34
Compare
Summary
clusterCollectionVerbsandnamespacedCollectionVerbsonRBACPreAuthorizerconfigurable viaWithClusterCollectionVerbsandWithNamespacedCollectionVerbsfunctional options, decoupling them from hardcoded verbs that were tightly coupled to contentmanagernamespacedCollectionVerbswithcreateclusterCollectionVerbswithlistandwatch(required by contentmanager)Closes #1911
Motivation
In Boxcutter, watching is done with the controller's service account which includes list/watch permissions across the cluster. Therefore, they are not required by the clusterextension's nominated service account. Once we fully switch to Boxcutter the option can be dropped entirely.
Making
namespacedCollectionVerbsconfigurable follows the same pattern, allowing appliers to explicitly declare their requirements rather than relying on hidden defaults.Test plan
WithNamespacedCollectionVerbsoptionWithClusterCollectionVerbsoption🤖 Generated with Claude Code