Skip to content

Conversation

@perdasilva
Copy link
Contributor

@perdasilva perdasilva commented Jan 13, 2026

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:

  • Refactors PreAuthorizer away from handling ClusterExtension specific permissions
  • Refactors Helm applier to add ClusterExtension permissions for the PreAuthorization check
  • Updates the Helm applier PreAuthorization unit tests and adds a component integration test to ensure it is being called with the right parameters
  • Adds PreAuthorization checks to the Boxcutter Applier and adds the clusterextensionrevisions/finalizers update permission for the check
  • Refactors Boxcutters createOrUpdate method to call perform the PreAuthorization checks
  • Adds PreAuthorizator intergration tests to Boxcutter unit test suite

PreAuthorizer Refactoring Notes

Previously, the PreAuthorizer.PreAuthorize method took a ClusterExtension as a parameter and used it to derive the user to check the permissions against and to generate the clusterextensions/finalizers update 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:

  • manifestManager -> the user to check the permissions agains
  • additionsRequiredPermissions -> permissions that are required on top of the permissions strictly required to manage the manifests input through the manifestReader parameter.

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

  • Added the 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 future
  • Refactored the templating functions to split concerns
  • Split the namespace and service account from the RBAC step into its own step (RBAC steps call the service account step - so their behavior hasn't changes completely) - this enables testing the ClusterExtension before the service account gets its permissions

Note

  • The Boxcutter applier still uses the manager client to create and update the revisions. The PreAuthorizer just ensures the service account has all the necessary permissions to do its job.

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

Copilot AI review requested due to automatic review settings January 13, 2026 14:42
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 13, 2026
@netlify
Copy link

netlify bot commented Jan 13, 2026

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 4b73a61
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/696fa67f32ca2e00080b677b
😎 Deploy Preview https://deploy-preview-2443--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a 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.

@perdasilva perdasilva force-pushed the boxcutter-preflight-auth-checks branch from 6f94c27 to 9d08956 Compare January 13, 2026 14:56
Copilot AI review requested due to automatic review settings January 13, 2026 15:00
@perdasilva perdasilva force-pushed the boxcutter-preflight-auth-checks branch from 9d08956 to 7cdc319 Compare January 13, 2026 15:00
@perdasilva perdasilva force-pushed the boxcutter-preflight-auth-checks branch 2 times, most recently from 876225e to 7f4a867 Compare January 13, 2026 15:25
@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

❌ Patch coverage is 90.12346% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.50%. Comparing base (a9e5614) to head (4b73a61).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
cmd/operator-controller/main.go 0.00% 4 Missing ⚠️
internal/operator-controller/applier/boxcutter.go 90.47% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2443      +/-   ##
==========================================
- Coverage   73.01%   69.50%   -3.52%     
==========================================
  Files         101      101              
  Lines        7730     7768      +38     
==========================================
- Hits         5644     5399     -245     
- Misses       1635     1932     +297     
+ Partials      451      437      -14     
Flag Coverage Δ
e2e 46.01% <0.00%> (-0.23%) ⬇️
experimental-e2e 13.43% <0.00%> (-36.33%) ⬇️
unit 57.20% <90.12%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a 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.

@perdasilva perdasilva force-pushed the boxcutter-preflight-auth-checks branch from 7f4a867 to d542d16 Compare January 13, 2026 17:09
@perdasilva perdasilva marked this pull request as ready for review January 13, 2026 17:09
Copilot AI review requested due to automatic review settings January 13, 2026 17:09
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 13, 2026
@openshift-ci openshift-ci bot requested review from joelanford and tmshort January 13, 2026 17:09
Copy link
Contributor

Copilot AI left a 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.

@perdasilva perdasilva force-pushed the boxcutter-preflight-auth-checks branch from d542d16 to 53a9309 Compare January 14, 2026 16:06
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 14, 2026
Copilot AI review requested due to automatic review settings January 14, 2026 16:08
@perdasilva perdasilva force-pushed the boxcutter-preflight-auth-checks branch from 53a9309 to 5cd737f Compare January 14, 2026 16:08
Copy link
Contributor

Copilot AI left a 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.

@perdasilva perdasilva force-pushed the boxcutter-preflight-auth-checks branch from 5cd737f to 2b041e5 Compare January 14, 2026 16:26
Copilot AI review requested due to automatic review settings January 14, 2026 16:28
@perdasilva perdasilva force-pushed the boxcutter-preflight-auth-checks branch from 2b041e5 to 13cdb4b Compare January 14, 2026 16:28
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 19, 2026
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 19, 2026
Copilot AI review requested due to automatic review settings January 20, 2026 07:53
@perdasilva perdasilva force-pushed the boxcutter-preflight-auth-checks branch from dd63342 to d0a8787 Compare January 20, 2026 07:53
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 20, 2026
Copy link
Contributor

Copilot AI left a 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 no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 270 to 284
type conditionMessageCmp func(string) bool

func condMsgEquals(expected string) conditionMessageCmp {
return func(actual string) bool {
return actual == expected
}
}

func condMsgContains(expected string) conditionMessageCmp {
return func(actual string) bool {
return strings.Contains(actual, expected)
}
}

func waitForCondition(ctx context.Context, resourceType, resourceName, conditionType, conditionStatus string, conditionReason *string, msgCmp *conditionMessageCmp) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about that we do this instead? I find it a bit more readable/understanble:

diff --git a/test/e2e/steps/steps.go b/test/e2e/steps/steps.go
index f888a042..ab097182 100644
--- a/test/e2e/steps/steps.go
+++ b/test/e2e/steps/steps.go
@@ -267,21 +267,11 @@ func waitFor(ctx context.Context, conditionFn func() bool) {
 	require.Eventually(godog.T(ctx), conditionFn, timeout, tick)
 }
 
-type conditionMessageCmp func(string) bool
+type msgMatchFn func(string) bool
 
-func condMsgEquals(expected string) conditionMessageCmp {
-	return func(actual string) bool {
-		return actual == expected
-	}
-}
+func alwaysMatch(_ string) bool { return true }
 
-func condMsgContains(expected string) conditionMessageCmp {
-	return func(actual string) bool {
-		return strings.Contains(actual, expected)
-	}
-}
-
-func waitForCondition(ctx context.Context, resourceType, resourceName, conditionType, conditionStatus string, conditionReason *string, msgCmp *conditionMessageCmp) error {
+func waitForCondition(ctx context.Context, resourceType, resourceName, conditionType, conditionStatus string, conditionReason *string, msgFn msgMatchFn) error {
 	require.Eventually(godog.T(ctx), func() bool {
 		v, err := k8sClient("get", resourceType, resourceName, "-o", fmt.Sprintf("jsonpath={.status.conditions[?(@.type==\"%s\")]}", conditionType))
 		if err != nil {
@@ -298,7 +288,7 @@ func waitForCondition(ctx context.Context, resourceType, resourceName, condition
 		if conditionReason != nil && condition.Reason != *conditionReason {
 			return false
 		}
-		if msgCmp != nil && !(*msgCmp)(condition.Message) {
+		if msgFn != nil && !msgFn(condition.Message) {
 			return false
 		}
 
@@ -307,25 +297,31 @@ func waitForCondition(ctx context.Context, resourceType, resourceName, condition
 	return nil
 }
 
-func waitForExtensionCondition(ctx context.Context, conditionType, conditionStatus string, conditionReason *string, msgCmp *conditionMessageCmp) error {
+func waitForExtensionCondition(ctx context.Context, conditionType, conditionStatus string, conditionReason *string, msgMatchFn msgMatchFn) error {
 	sc := scenarioCtx(ctx)
-	return waitForCondition(ctx, "clusterextension", sc.clusterExtensionName, conditionType, conditionStatus, conditionReason, msgCmp)
+	return waitForCondition(ctx, "clusterextension", sc.clusterExtensionName, conditionType, conditionStatus, conditionReason, msgMatchFn)
 }
 
 func ClusterExtensionReportsCondition(ctx context.Context, conditionType, conditionStatus, conditionReason string, msg *godog.DocString) error {
-	var conditionMsgCmp *conditionMessageCmp
+	cmp := alwaysMatch
 	if msg != nil {
-		conditionMsgCmp = ptr.To(condMsgEquals(substituteScenarioVars(strings.Join(strings.Fields(msg.Content), " "), scenarioCtx(ctx))))
+		expectedMsg := substituteScenarioVars(msg.Content, scenarioCtx(ctx))
+		cmp = func(v string) bool {
+			return v == expectedMsg
+		}
 	}
-	return waitForExtensionCondition(ctx, conditionType, conditionStatus, &conditionReason, conditionMsgCmp)
+	return waitForExtensionCondition(ctx, conditionType, conditionStatus, &conditionReason, cmp)
 }
 
 func ClusterExtensionReportsConditionWithMessageFragment(ctx context.Context, conditionType, conditionStatus, conditionReason string, msgFragment *godog.DocString) error {
-	var conditionMsgCmp *conditionMessageCmp
+	cmp := alwaysMatch
 	if msgFragment != nil {
-		conditionMsgCmp = ptr.To(condMsgContains(substituteScenarioVars(strings.Join(strings.Fields(msgFragment.Content), " "), scenarioCtx(ctx))))
+		expectedMsg := substituteScenarioVars(strings.Join(strings.Fields(msgFragment.Content), " "), scenarioCtx(ctx))
+		cmp = func(actual string) bool {
+			return strings.Contains(actual, expectedMsg)
+		}
 	}
-	return waitForExtensionCondition(ctx, conditionType, conditionStatus, &conditionReason, conditionMsgCmp)
+	return waitForExtensionCondition(ctx, conditionType, conditionStatus, &conditionReason, cmp)
 }
 
 func ClusterExtensionReportsConditionWithoutMsg(ctx context.Context, conditionType, conditionStatus, conditionReason string) error {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

brought these changes over - in hindsight I should have used patch XDD

@perdasilva perdasilva force-pushed the boxcutter-preflight-auth-checks branch from d0a8787 to b138ee8 Compare January 20, 2026 14:04
Copilot AI review requested due to automatic review settings January 20, 2026 15:21
@perdasilva perdasilva force-pushed the boxcutter-preflight-auth-checks branch from b138ee8 to 941193f Compare January 20, 2026 15:21
Copy link
Contributor

Copilot AI left a 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 12 out of 12 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@perdasilva perdasilva force-pushed the boxcutter-preflight-auth-checks branch from 941193f to 859c541 Compare January 20, 2026 15:39
Copy link
Contributor

@pedjak pedjak left a comment

Choose a reason for hiding this comment

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

/lgtm

Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 20, 2026
Copilot AI review requested due to automatic review settings January 20, 2026 15:59
@perdasilva perdasilva force-pushed the boxcutter-preflight-auth-checks branch from 859c541 to 4b73a61 Compare January 20, 2026 15:59
@openshift-ci
Copy link

openshift-ci bot commented Jan 20, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pedjak, tmshort

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 20, 2026
Copy link
Contributor

Copilot AI left a 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 12 out of 12 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pedjak
Copy link
Contributor

pedjak commented Jan 20, 2026

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 20, 2026
@camilamacedo86
Copy link
Contributor

/override codecov/project

@openshift-ci
Copy link

openshift-ci bot commented Jan 20, 2026

@camilamacedo86: Overrode contexts on behalf of camilamacedo86: codecov/project

Details

In response to this:

/override codecov/project

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-merge-bot openshift-merge-bot bot merged commit 3c247ee into operator-framework:main Jan 20, 2026
35 of 36 checks passed
@grokspawn
Copy link
Contributor

overrides across openshift/operator-framework domain cannot work.
However, codecov is not a required test in this repo, so it just may be taking a minute to process (it's batching).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants