Skip to content

⚠ make spec.namespace optional with managed namespace support and PSA support#2825

Draft
nader-ziada wants to merge 2 commits into
operator-framework:mainfrom
nader-ziada:feat/namespace-psa
Draft

⚠ make spec.namespace optional with managed namespace support and PSA support#2825
nader-ziada wants to merge 2 commits into
operator-framework:mainfrom
nader-ziada:feat/namespace-psa

Conversation

@nader-ziada

Copy link
Copy Markdown

Description

When spec.namespace is omitted, operator-controller resolves a managed namespace from bundle metadata using the fallback chain: suggested-namespace-template > suggested-namespace > -system.

The managed namespace is included as a ClusterObjectSet object with collision protection. Pod Security Admission labels from the bundle's suggested-namespace-template annotation are applied to the managed namespace, enabling operators to declare their PSA requirements

Reviewer Checklist

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

…t and PSA support

When spec.namespace is omitted, operator-controller resolves a managed
namespace from bundle metadata using the fallback chain:
suggested-namespace-template > suggested-namespace > <packageName>-system.

The managed namespace is included as a ClusterObjectSet object with
collision protection. Pod Security Admission labels from the bundle's
suggested-namespace-template annotation are applied to the managed
namespace, enabling operators to declare their PSA requirements

Signed-off-by: Nader Ziada <nziada@redhat.com>
Copilot AI review requested due to automatic review settings July 22, 2026 16:10
@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 Jul 22, 2026
@openshift-ci

openshift-ci Bot commented Jul 22, 2026

Copy link
Copy Markdown

[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 tmshort for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@netlify

netlify Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 56fee54
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/6a6146cc3ca9ab0008a58860
😎 Deploy Preview https://deploy-preview-2825--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR makes ClusterExtension.spec.namespace optional by introducing “managed namespace” behavior resolved from bundle CSV annotations (including PSA label support), and updates reconciliation + tests/docs accordingly.

Changes:

  • Add managed-namespace resolution from bundle metadata with a fallback chain and persist the resolved namespace in status.
  • Inject a managed Namespace object (with collision protection) and support applying PSA labels via suggested-namespace-template.
  • Expand E2E/unit tests and update CRD schema/docs to reflect optional namespace + immutability rules.

Reviewed changes

Copilot reviewed 25 out of 29 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
test/internal/catalog/bundle.go Adds test helpers to annotate CSVs (namespace template / PSA).
test/e2e/steps/steps.go Adds godog steps to assert Namespace labels and parses NSTemplate bundle content option.
test/e2e/features/namespace.feature New E2E scenarios validating PSA labels on managed namespaces and absence on user namespaces.
manifests/standard.yaml Makes spec.namespace optional, adds immutability CEL rules, and adds status.namespace.
manifests/standard-e2e.yaml Same as standard.yaml for e2e manifests.
manifests/experimental.yaml Same namespace optionality + status field changes for experimental.
manifests/experimental-e2e.yaml Same as experimental.yaml for e2e manifests.
internal/operator-controller/controllers/clusterobjectset_controller.go Improves collision error messages, especially for Namespaces.
internal/operator-controller/controllers/clusterextension_reconcile_steps.go Adds ResolveNamespace reconcile step; sets status.namespace during apply.
internal/operator-controller/controllers/clusterextension_controller_test.go Adds unit test coverage for ResolveNamespace (user-provided namespace existence).
internal/operator-controller/controllers/clusterextension_controller.go Extends reconcile state with resolved namespace + managed/template flags.
internal/operator-controller/controllers/clusterextension_admission_test.go Updates admission expectations (namespace optional) and adds namespace immutability tests.
internal/operator-controller/controllers/boxcutter_reconcile_steps_apply_test.go Updates boxcutter apply step signature to accept NamespaceConfig.
internal/operator-controller/controllers/boxcutter_reconcile_steps.go Passes NamespaceConfig into boxcutter apply and sets status.namespace.
internal/operator-controller/applier/provider.go Exports GetBundleAnnotations for namespace resolution usage.
internal/operator-controller/applier/namespace_test.go Adds unit tests for parsing templates, resolving names, and building Namespace objects.
internal/operator-controller/applier/namespace.go Implements template parsing, namespace resolution, and Namespace object construction.
internal/operator-controller/applier/boxcutter_test.go Updates revision generator tests for namespace phase injection and ordering.
internal/operator-controller/applier/boxcutter.go Threads NamespaceConfig through revision generation and boxcutter apply; injects Namespace object when managed.
helm/olmv1/base/operator-controller/crd/standard/olm.operatorframework.io_clusterextensions.yaml Helm CRD: makes namespace optional + adds status.namespace + CEL immutability rules.
helm/olmv1/base/operator-controller/crd/experimental/olm.operatorframework.io_clusterextensions.yaml Helm CRD: same as standard for experimental.
docs/howto/namespace-configuration-for-authors.md New author-facing docs for namespace annotations and PSA template usage.
docs/concepts/managed-namespaces.md New concept doc describing managed namespaces, deletion behavior, and PSA labels.
cmd/operator-controller/main.go Wires ResolveNamespace into both boxcutter and helm reconcilers.
api/v1/clusterextension_types.go Updates API docs/validation and adds status.namespace field.
Files not reviewed (4)
  • applyconfigurations/api/v1/clusterextensionspec.go: Generated file
  • applyconfigurations/api/v1/clusterextensionstatus.go: Generated file
  • applyconfigurations/internal/internal.go: Generated file
  • internal/testutil/mock/applier/mock_applier.go: Generated file

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

Comment thread internal/operator-controller/controllers/clusterextension_reconcile_steps.go Outdated
Comment thread internal/operator-controller/applier/namespace.go
Comment thread internal/operator-controller/controllers/clusterobjectset_controller.go Outdated
Copilot AI review requested due to automatic review settings July 22, 2026 18:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 25 out of 29 changed files in this pull request and generated 4 comments.

Files not reviewed (4)
  • applyconfigurations/api/v1/clusterextensionspec.go: Generated file
  • applyconfigurations/api/v1/clusterextensionstatus.go: Generated file
  • applyconfigurations/internal/internal.go: Generated file
  • internal/testutil/mock/applier/mock_applier.go: Generated file
Comments suppressed due to low confidence (1)

internal/operator-controller/controllers/clusterextension_admission_test.go:290

  • Typo in the test case name: "hypen-separated" should be "hyphen-separated".
	}{
		{"just alphanumeric", "justalphanumberic1", ""},
		{"hypen-separated", "hyphenated-name", ""},
		{"no install namespace (managed mode)", "", ""},
		{"dot-separated", "dotted.name", regexMismatchError},

Comment thread internal/operator-controller/controllers/clusterextension_reconcile_steps.go Outdated
Comment thread internal/operator-controller/controllers/clusterextension_reconcile_steps.go Outdated
Comment thread internal/operator-controller/controllers/clusterextension_reconcile_steps.go Outdated
Comment thread internal/operator-controller/controllers/clusterextension_reconcile_steps.go Outdated
Copilot AI review requested due to automatic review settings July 22, 2026 19:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 25 out of 29 changed files in this pull request and generated 2 comments.

Files not reviewed (4)
  • applyconfigurations/api/v1/clusterextensionspec.go: Generated file
  • applyconfigurations/api/v1/clusterextensionstatus.go: Generated file
  • applyconfigurations/internal/internal.go: Generated file
  • internal/testutil/mock/applier/mock_applier.go: Generated file
Comments suppressed due to low confidence (1)

internal/operator-controller/controllers/clusterextension_admission_test.go:288

  • Typo in the test case name: "hypen-separated" should be "hyphen-separated".
		{"hypen-separated", "hyphenated-name", ""},

Comment thread internal/operator-controller/applier/namespace.go
Comment thread cmd/operator-controller/main.go
Copilot AI review requested due to automatic review settings July 22, 2026 21:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 25 out of 29 changed files in this pull request and generated 2 comments.

Files not reviewed (4)
  • applyconfigurations/api/v1/clusterextensionspec.go: Generated file
  • applyconfigurations/api/v1/clusterextensionstatus.go: Generated file
  • applyconfigurations/internal/internal.go: Generated file
  • internal/testutil/mock/applier/mock_applier.go: Generated file
Comments suppressed due to low confidence (1)

internal/operator-controller/controllers/clusterextension_admission_test.go:288

  • The test case name has a typo: "hypen-separated" should be "hyphen-separated" (this is just the display name for the subtest, but it’s misleading when reading test output).
		{"hypen-separated", "hyphenated-name", ""},

Comment thread internal/operator-controller/applier/boxcutter.go
}

func getBundleAnnotations(bundleFS fs.FS) (map[string]string, error) {
func GetBundleAnnotations(bundleFS fs.FS) (map[string]string, error) {
Signed-off-by: Nader Ziada <nziada@redhat.com>
Copilot AI review requested due to automatic review settings July 22, 2026 22:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 25 out of 29 changed files in this pull request and generated no new comments.

Files not reviewed (4)
  • applyconfigurations/api/v1/clusterextensionspec.go: Generated file
  • applyconfigurations/api/v1/clusterextensionstatus.go: Generated file
  • applyconfigurations/internal/internal.go: Generated file
  • internal/testutil/mock/applier/mock_applier.go: Generated file
Comments suppressed due to low confidence (1)

internal/operator-controller/controllers/clusterextension_admission_test.go:288

  • Typo in test case name: "hypen-separated" should be "hyphen-separated".
		{"hypen-separated", "hyphenated-name", ""},

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