-
Notifications
You must be signed in to change notification settings - Fork 71
✨ Add ServiceAccount validation to ClusterExtension reconciliation #2488
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?
Conversation
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
[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 |
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 ServiceAccount validation to the ClusterExtension reconciliation pipeline. The validation checks whether the ServiceAccount specified in .spec.serviceAccount exists on the cluster before proceeding with bundle installation, moving this check from RetrieveRevisionStates to an earlier validation stage.
Changes:
- Introduces a new validation framework with
ValidateClusterExtensionorchestrator andServiceAccountValidatorimplementation - Moves ServiceAccount existence checks earlier in the reconciliation pipeline (after finalizer handling)
- Updates both Boxcutter and Helm reconciler configurations to include the validation step
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
internal/operator-controller/controllers/clusterextension_reconcile_steps.go |
Adds validation framework (ValidateClusterExtension, ClusterExtensionValidator, ServiceAccountValidator) and removes ServiceAccount error handling from RetrieveRevisionStates |
internal/operator-controller/controllers/clusterextension_reconcile_steps_test.go |
Adds comprehensive unit tests for validator functions (10 test cases total) |
internal/operator-controller/controllers/clusterextension_controller_test.go |
Updates existing ServiceAccount test to use new validation approach with mock TokenGetter |
cmd/operator-controller/main.go |
Integrates validation step into both Boxcutter and Helm reconciler configurations |
test/e2e/features/install.feature |
Adds E2E Gherkin scenario for ServiceAccount validation error case |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
internal/operator-controller/controllers/clusterextension_controller_test.go
Outdated
Show resolved
Hide resolved
internal/operator-controller/controllers/clusterextension_reconcile_steps.go
Outdated
Show resolved
Hide resolved
internal/operator-controller/controllers/clusterextension_reconcile_steps.go
Outdated
Show resolved
Hide resolved
internal/operator-controller/controllers/clusterextension_reconcile_steps_test.go
Outdated
Show resolved
Hide resolved
internal/operator-controller/controllers/clusterextension_reconcile_steps.go
Outdated
Show resolved
Hide resolved
internal/operator-controller/controllers/clusterextension_reconcile_steps_test.go
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2488 +/- ##
==========================================
+ Coverage 69.73% 69.84% +0.11%
==========================================
Files 102 102
Lines 8471 8520 +49
==========================================
+ Hits 5907 5951 +44
- Misses 2091 2096 +5
Partials 473 473
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:
|
26b9052 to
58f8e47
Compare
58f8e47 to
64a00b6
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 5 out of 5 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
internal/operator-controller/controllers/clusterextension_reconcile_steps.go
Show resolved
Hide resolved
internal/operator-controller/controllers/clusterextension_reconcile_steps_test.go
Outdated
Show resolved
Hide resolved
internal/operator-controller/controllers/clusterextension_reconcile_steps_test.go
Outdated
Show resolved
Hide resolved
internal/operator-controller/controllers/clusterextension_reconcile_steps.go
Outdated
Show resolved
Hide resolved
64a00b6 to
8e814fb
Compare
| revisionStates, err := r.GetRevisionStates(ctx, ext) | ||
| if err != nil { | ||
| setInstallStatus(ext, nil) | ||
| var saerr *authentication.ServiceAccountNotFoundError |
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.
this got split between the service account validator and the cluster extension validator
8e814fb to
cf4cdb1
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 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
internal/operator-controller/controllers/clusterextension_controller_test.go
Outdated
Show resolved
Hide resolved
internal/operator-controller/controllers/clusterextension_controller_test.go
Show resolved
Hide resolved
cf4cdb1 to
a946319
Compare
a946319 to
81c68c3
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 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
internal/operator-controller/controllers/clusterextension_controller_test.go
Outdated
Show resolved
Hide resolved
…erExtension Introduces an extensible validation framework that runs early in the ClusterExtension reconciliation pipeline to catch configuration errors before expensive operations begin. The first validator checks whether the specified ServiceAccount exists, providing clear feedback when it's missing. The validation step: - Executes all validators and collects all errors (no fail-fast) - Reuses the same TokenGetter cache for both validation and bundle operations - Sets appropriate status conditions (Installed=Unknown, Progressing=Retrying) - Provides user-friendly error messages This architectural improvement separates validation concerns from revision state retrieval, making it easier to add new validators in the future. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
81c68c3 to
6d40acc
Compare
Summary
This PR introduces an extensible validation framework for ClusterExtension reconciliation that validates configuration before attempting bundle installation. The first validator ensures the specified ServiceAccount exists.
Problem
Previously, ServiceAccount validation happened during revision state retrieval, which meant:
Solution
New Validation Framework
ValidateClusterExtension(validators ...ClusterExtensionValidator)Installed: UnknownProgressing: True (Reason: Retrying)ServiceAccountValidator(tokenGetter)service account "name" not found in namespace "ns"Integration Points
Added as the first reconcile step (after finalizer handling) in both:
The same
tokenGetterinstance is created once and shared across validation and bundle operations.Cleanup
Removed ServiceAccount-specific error handling from
RetrieveRevisionStatessince validation now happens earlier in the pipeline.Testing
Unit Tests (
clusterextension_controller_test.go)TestValidateClusterExtension- 7 scenarios:TestClusterExtensionServiceAccountNotFoundE2E Tests (
test/e2e/features/install.feature)Benefits
Extensibility
User Experience
Performance
Maintainability
Files Changed
cmd/operator-controller/main.go(+9/-9)internal/operator-controller/controllers/clusterextension_reconcile_steps.go(+57/-6)internal/operator-controller/controllers/clusterextension_controller_test.go(+193/-15)test/e2e/features/install.feature(+24)🤖 Generated with Claude Code