Skip to content

Conversation

@grokspawn
Copy link
Contributor

Description

Addresses review comments (including new unit, e2e tests) and adds capabilities to the generate-crd tool to handle new optional/required scoped validations which required a change in the API to inform the schema parent to adjust its required list entries based on the desired scoped validation.

(Yes, there appear to be some additional files in here which are unrelated. For a throwaway draft PR, I'm not going to worry about them. )

Reviewer Checklist

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

trgeiger and others added 2 commits November 13, 2025 15:36
Changes the ClusterExtension API field spec.ServiceAccount to be
optional. Operator-controller will use its own service account by
default unless the spec.ServiceAccount field is set. RBAC
PreAuthorization only happens if the optional SA field is set, as well.

Give operator-controller's SA cluster-admin by default.
…ard/experimental .spec.serviceaccount handling

Signed-off-by: grokspawn <[email protected]>
Copilot AI review requested due to automatic review settings November 20, 2025 21:41
@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 Nov 20, 2025
@openshift-ci
Copy link

openshift-ci bot commented Nov 20, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kevinrizza for approval. For more information see the Code Review Process.

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

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

@netlify
Copy link

netlify bot commented Nov 20, 2025

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 5dbac40
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/691f8afa2da24a0008e752d2
😎 Deploy Preview https://deploy-preview-2355--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.

Copilot finished reviewing on behalf of grokspawn November 20, 2025 21:43
Copy link

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 makes the serviceAccount field optional in the experimental channel while keeping it required in the standard channel. The changes enable operator-controller to use its own ServiceAccount (with synthetic user permissions) when no ServiceAccount is specified, supporting a new installation mode. Key implementation aspects include:

  • Modified API types to use channel-specific validation tags
  • Enhanced the CRD generator tool to handle optional/required field scoping
  • Updated controller logic to conditionally skip authorization checks when ServiceAccount is not provided
  • Elevated operator-controller permissions to cluster-admin to support the new mode
  • Added comprehensive E2E and unit tests

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
api/v1/clusterextension_types.go Added channel-specific descriptions and validations for ServiceAccount field, changed to omitzero JSON tag, fixed typo
api/v1/clusterextension_types_test.go Added unit tests for ServiceAccount JSON marshaling behavior with omitzero
hack/tools/crd-generator/main.go Enhanced to handle Optional/Required validation tags and propagate required field changes to parent schemas
helm/olmv1/base/operator-controller/crd/standard/olm.operatorframework.io_clusterextensions.yaml Generated CRD with updated ServiceAccount description for standard channel
helm/olmv1/base/operator-controller/crd/experimental/olm.operatorframework.io_clusterextensions.yaml Generated CRD with optional ServiceAccount for experimental channel
manifests/standard.yaml Updated CRD and changed operator-controller to cluster-admin role binding
manifests/standard-e2e.yaml Updated CRD and changed operator-controller to cluster-admin role binding
manifests/experimental.yaml Updated CRD for optional ServiceAccount, changed role binding name
manifests/experimental-e2e.yaml Updated CRD for optional ServiceAccount, changed role binding name
helm/olmv1/templates/rbac/clusterrolebinding-operator-controller-manager-rolebinding.yml Simplified to always use cluster-admin role, removed conditional logic
internal/operator-controller/applier/helm.go Added check to skip pre-authorization when ServiceAccount name is empty
internal/operator-controller/action/restconfig.go Added logic to use operator-controller's ServiceAccount when none is specified
internal/operator-controller/controllers/clusterextension_admission_test.go Updated test to reflect that empty ServiceAccount name is now valid
test/e2e/cluster_extension_install_test.go Added E2E test for installation without ServiceAccount using synthetic user
docs/api-reference/olmv1-api-reference.md Updated documentation with raw opcon tags instead of processed descriptions

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

| --- | --- | --- | --- |
| `namespace` _string_ | namespace is a reference to a Kubernetes namespace.<br />This is the namespace in which the provided ServiceAccount must exist.<br />It also designates the default namespace where namespace-scoped resources<br />for the extension are applied to the cluster.<br />Some extensions may contain namespace-scoped resources to be applied in other namespaces.<br />This namespace must exist.<br />namespace is required, immutable, and follows the DNS label standard<br />as defined in [RFC 1123]. It must contain only lowercase alphanumeric characters or hyphens (-),<br />start and end with an alphanumeric character, and be no longer than 63 characters<br />[RFC 1123]: https://tools.ietf.org/html/rfc1123 | | MaxLength: 63 <br />Required: \{\} <br /> |
| `serviceAccount` _[ServiceAccountReference](#serviceaccountreference)_ | serviceAccount is a reference to a ServiceAccount used to perform all interactions<br />with the cluster that are required to manage the extension.<br />The ServiceAccount must be configured with the necessary permissions to perform these interactions.<br />The ServiceAccount must exist in the namespace referenced in the spec.<br />serviceAccount is required. | | Required: \{\} <br /> |
| `serviceAccount` _[ServiceAccountReference](#serviceaccountreference)_ | <opcon:standard:description><br />serviceAccount is a required field that references a ServiceAccount used to<br />perform all interactions with the cluster that are required to manage the extension.<br /></opcon:standard:description><br /><opcon:standard:validation:Required><br /><opcon:experimental:description><br />serviceAccount is an optional field that references a ServiceAccount used to<br />perform all interactions with the cluster that are required to manage the extension.<br />If not set, operator-controller will use its own ServiceAccount for extension management.<br />The ServiceAccount must be configured with the necessary permissions to perform these interactions.<br />The ServiceAccount must exist in the namespace referenced in the spec.<br /></opcon:experimental:description><br /><opcon:experimental:validation:Optional> | | |
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

The documentation contains raw <opcon:*> tags that should have been processed by the CRD generator. These internal markup tags should not appear in end-user documentation. The formatDescription function should have removed or processed these tags to show only the appropriate channel-specific content.

Suggested change
| `serviceAccount` _[ServiceAccountReference](#serviceaccountreference)_ | <opcon:standard:description><br />serviceAccount is a required field that references a ServiceAccount used to<br />perform all interactions with the cluster that are required to manage the extension.<br /></opcon:standard:description><br /><opcon:standard:validation:Required><br /><opcon:experimental:description><br />serviceAccount is an optional field that references a ServiceAccount used to<br />perform all interactions with the cluster that are required to manage the extension.<br />If not set, operator-controller will use its own ServiceAccount for extension management.<br />The ServiceAccount must be configured with the necessary permissions to perform these interactions.<br />The ServiceAccount must exist in the namespace referenced in the spec.<br /></opcon:experimental:description><br /><opcon:experimental:validation:Optional> | | |
| `serviceAccount` _[ServiceAccountReference](#serviceaccountreference)_ | serviceAccount is a required field that references a ServiceAccount used to perform all interactions with the cluster that are required to manage the extension.<br />**Experimental:** serviceAccount is an optional field that references a ServiceAccount used to perform all interactions with the cluster that are required to manage the extension. If not set, operator-controller will use its own ServiceAccount for extension management. The ServiceAccount must be configured with the necessary permissions to perform these interactions. The ServiceAccount must exist in the namespace referenced in the spec. | | Required (standard), Optional (experimental) |

Copilot uses AI. Check for mistakes.
Comment on lines +135 to +136
serviceAccount is a required field that references a ServiceAccount used to
perform all interactions with the cluster that are required to manage the extension.
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

The description states that serviceAccount is 'a required field' but the required list at line 173 has been removed, making this field actually optional in the CRD schema. This creates an inconsistency between the description and the actual schema enforcement. For the standard channel, either the description should be corrected to say it's optional, or the field should remain in the required list.

Copilot uses AI. Check for mistakes.
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
{{- if has "BoxcutterRuntime" .Values.options.operatorController.features.enabled }}
name: cluster-admin
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Binding operator-controller to cluster-admin grants unrestricted access to all cluster resources. This is overly permissive and violates the principle of least privilege. The operator-controller should only have the specific permissions it needs to manage ClusterExtensions. Consider creating a custom ClusterRole with only the necessary permissions (e.g., managing CRDs, deployments, services, RBAC resources in specific contexts) instead of using cluster-admin.

Suggested change
name: cluster-admin
name: operator-controller-manager-role

Copilot uses AI. Check for mistakes.
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: operator-controller-manager-role
name: cluster-admin
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Binding operator-controller to cluster-admin grants unrestricted access to all cluster resources. This is overly permissive and violates the principle of least privilege. The operator-controller should only have the specific permissions it needs to manage ClusterExtensions. Consider creating a custom ClusterRole with only the necessary permissions instead of using cluster-admin.

Copilot uses AI. Check for mistakes.
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: operator-controller-manager-role
name: cluster-admin
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Binding operator-controller to cluster-admin grants unrestricted access to all cluster resources. This is overly permissive and violates the principle of least privilege. The operator-controller should only have the specific permissions it needs to manage ClusterExtensions. Consider creating a custom ClusterRole with only the necessary permissions instead of using cluster-admin.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants