-
Notifications
You must be signed in to change notification settings - Fork 70
✨ Add preauthorizer checks to Boxcutter applier #2443
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
base: main
Are you sure you want to change the base?
✨ Add preauthorizer checks to Boxcutter applier #2443
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds PreAuthorizer checks to the Boxcutter applier to achieve feature-gate parity with the Helm applier. The implementation validates that service accounts have the necessary RBAC permissions before applying cluster extensions, including the ability to update clusterextensionrevisions/finalizers which is specific to the Boxcutter workflow.
Changes:
- Added an Option pattern to configure PreAuthorizer with ClusterExtensionRevision finalizer permission checks
- Integrated PreAuthorizer into the Boxcutter applier with manifest generation and permission validation
- Updated main.go to initialize PreAuthorizer with the new option when the PreflightPermissions feature gate is enabled
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/operator-controller/authorization/rbac.go | Added Option pattern and WithClusterExtensionRevisionPerms to optionally check for update permissions on clusterextensionrevisions/finalizers |
| internal/operator-controller/authorization/rbac_test.go | Added test case for PreAuthorizer with ClusterExtensionRevision permissions |
| internal/operator-controller/applier/boxcutter.go | Added PreAuthorizer field and runPreAuthorizationChecks method to validate permissions before applying revisions |
| internal/operator-controller/applier/boxcutter_test.go | Added integration test for PreAuthorizer with fake implementation |
| cmd/operator-controller/main.go | Initialize PreAuthorizer with WithClusterExtensionRevisionPerms option when PreflightPermissions feature gate is enabled |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6f94c27 to
9d08956
Compare
9d08956 to
7cdc319
Compare
876225e to
7f4a867
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2443 +/- ##
==========================================
+ Coverage 69.48% 73.67% +4.18%
==========================================
Files 101 101
Lines 7701 7741 +40
==========================================
+ Hits 5351 5703 +352
+ Misses 1914 1592 -322
- Partials 436 446 +10
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:
|
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
7f4a867 to
d542d16
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.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d542d16 to
53a9309
Compare
53a9309 to
5cd737f
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.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5cd737f to
2b041e5
Compare
2b041e5 to
13cdb4b
Compare
|
/hold I think I've found an issue |
12ab842 to
b295770
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 |
|
/uhold |
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.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/unhold |
pedjak
left a comment
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.
one or more e2e tests asserting the behavior would be very helpful to add.
| return strings.NewReader(manifestBuilder.String()), nil | ||
| } | ||
|
|
||
| func clusterExtensionRevisionManagementPermissions(manifestManager user.Info, rev *ocv1.ClusterExtensionRevision) []authorizer.AttributesRecord { |
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.
nit: can we come up with some shorter function name perhaps?
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.
Updated to revisionManagementPerms, I also updated the other one to extManagementPerms
| func (bc *Boxcutter) createOrUpdate(ctx context.Context, obj client.Object) error { | ||
| if obj.GetObjectKind().GroupVersionKind().Empty() { | ||
| gvk, err := apiutil.GVKForObject(obj, bc.Scheme) | ||
| func (bc *Boxcutter) createOrUpdateRevisionWithPreAuthorization(ctx context.Context, ext *ocv1.ClusterExtension, rev *ocv1.ClusterExtensionRevision) error { |
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.
nit: was function name changing needed? createOrUpdate was nice and short. Perhaps we do not need to pass ClusterExtension to just extract user infos, we could actually pass userinfos here instead?
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'd say if there's you're adding a side-effect it's a good idea to change the function. Also, it's a private function, so it's it shouldn't an issue. But, I'm not married to it. I've reverted the name and added a call out to the side-effect to godoc and refactored the function signature.
b295770 to
d489d7b
Compare
d489d7b to
85dfbf8
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.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
85dfbf8 to
c96c4bc
Compare
|
|
||
| // runPreAuthorizationChecks runs PreAuthorization checks if the PreAuthorizer is set. An error will be returned if | ||
| // the ClusterExtension service account does not have the necessary permissions to manage the revision's resources | ||
| func (bc *Boxcutter) runPreAuthorizationChecks(ctx context.Context, manifestManager user.Info, rev *ocv1.ClusterExtensionRevision) error { |
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 know that you're taking this variable name from the example already set in rbac.go, but to me the term "manifestManager" implies a more complex object than just user.Info, especially given we have stuff like the manager.Manager in our codebase.
This is purely a nitpick, but I wonder if a different variable name would help future legibility of the code. Maybe manifestUser? or manifestOwner? The latter might not be entirely accurate though.
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 took the previous variable name, I think. Though, I'm happy to updated it to anything. The reason I thought manifestManager was reasonable is that it fits with the mental model of "we're checking permissions against the user that will manage the lifecycle of these manifests". Even just, user would be ok, imo, tho.
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 updated to just user
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.
Yeah, user works. I see what you're saying about manifestManager, it definitely makes sense but I think it carries a bit of implied complexity that doesn't seem to fit. User is perfect.
c96c4bc to
40a2645
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.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
40a2645 to
325f80d
Compare
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
325f80d to
12adada
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.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| require.Len(t, perms, 1) | ||
| require.Equal(t, authorizer.AttributesRecord{ | ||
| User: user, | ||
| Name: "test-ext-1", |
Copilot
AI
Jan 16, 2026
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.
The revision name is hardcoded as 'test-ext-1' but doesn't match the ClusterExtension name 'test-ext' defined on line 964. This appears to be intentional based on revision naming conventions, but consider adding a comment explaining why the name differs or deriving it from the extension name for clarity.
Description
Adds the PreAuthorizer checks to the Boxcutter applier for feature-gate parity between Helm and Boxcutter appliers.
The Boxcutter applier's PreAuthorization check requires clusterextensions/finalizers and clusterextensionrevisions/finalizers update permissions (on top of the permissions to manage the bundle's resources).
Changes:
createOrUpdatemethod to call perform the PreAuthorization checksPreAuthorizer Refactoring Notes
Previously, the
PreAuthorizer.PreAuthorizemethod took a ClusterExtension as a parameter and used it to derive the user to check the permissions against and to generate theclusterextensions/finalizersupdate permission implicitly required by the applier to manage update ownerReferences blockerOwnerDeletion.This PR makes refactors the PreAuthorize methods to substitute the ClusterExtension parameter by two parameters:
This makes the PreAuthorizer more generic by removing ClusterExtension concerns, and allows the applier to define which permissions are needed for its operation beyond those dictated by the bundle manifests. Making the PreAuthorizer more generic, and moving applier specific concerns to the applier. The PreAuthorizer and Applier unit tests are update for this change (removing the clusterextensionrevision perms from the PreAuthorizer tests and adding that check to the applier).
E2E Notes
ClusterExtension reports <condition> as <status> with Reason <reason> and Message including <message fragment>to avoid checking the entire error message but only the salient points as the set could change in the futureNote
Reviewer Checklist