Skip to content

Commit 0647768

Browse files
authored
⚠ make spec.namespace optional in the experimental channel (#2929)
* feat(api): make spec.namespace optional in the experimental channel On the experimental channel spec.namespace may now be omitted, in which case operator-controller resolves and creates a managed namespace from the bundle's metadata. Whether the field is set or omitted is locked at creation time: it cannot be added, removed, or changed afterwards. The standard channel keeps the existing required and immutable contract. Signed-off-by: Nader Ziada <nziada@redhat.com> * Document managed namespace relocation risk Warn that changing bundle namespace metadata during an upgrade can cause revision archival to delete the previous managed namespace and its contents. Document stable namespace metadata and explicit migration guidance. Signed-off-by: Nader Ziada <nziada@redhat.com> * Clarify managed namespace lifecycle Document namespace relocation behavior and bundle-author guidance, label experimental API-reference fields, and strengthen managed-namespace coverage. Signed-off-by: Nader Ziada <nziada@redhat.com> --------- Signed-off-by: Nader Ziada <nziada@redhat.com>
1 parent 435af42 commit 0647768

21 files changed

Lines changed: 623 additions & 61 deletions

File tree

‎Makefile‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,16 @@ crd-ref-docs: $(CRD_REF_DOCS) #EXHELP Generate the API Reference Documents.
685685
$(CRD_REF_DOCS) --source-path=$(ROOT_DIR)/api/ \
686686
--config=$(API_REFERENCE_DIR)/crd-ref-docs-gen-config.yaml \
687687
--renderer=markdown --output-path=$(API_REFERENCE_DIR)/$(API_REFERENCE_FILENAME);
688+
# crd-ref-docs renders doc-comment text verbatim, including internal <opcon:...> generator
689+
# directives. The reference covers both channels at once, so label the channel-specific
690+
# description blocks rather than dropping the tags silently -- otherwise a field documented
691+
# per channel reads as self-contradictory. Remaining directives are stripped.
692+
sed -E -e 's#<opcon:standard:description>#**Standard channel:** #g' \
693+
-e 's#<opcon:experimental:description>#**Experimental channel:** #g' \
694+
-e 's#<opcon:experimental>#**Experimental channel:** #g' \
695+
-e 's#</?opcon:[^>]*>##g' \
696+
$(API_REFERENCE_DIR)/$(API_REFERENCE_FILENAME) > $(API_REFERENCE_DIR)/$(API_REFERENCE_FILENAME).tmp
697+
mv $(API_REFERENCE_DIR)/$(API_REFERENCE_FILENAME).tmp $(API_REFERENCE_DIR)/$(API_REFERENCE_FILENAME)
688698

689699
VENVDIR := $(abspath docs/.venv)
690700

‎api/v1/clusterextension_types.go‎

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const (
5050
// ClusterExtensionSpec defines the desired state of ClusterExtension
5151
type ClusterExtensionSpec struct {
5252
// namespace specifies a Kubernetes namespace.
53-
// It designates the default namespace where namespace-scoped resources for the extension are applied to the cluster.
53+
// <opcon:standard:description>It designates the default namespace where namespace-scoped resources for the extension are applied to the cluster.
5454
// Some extensions may contain namespace-scoped resources to be applied in other namespaces.
5555
// This namespace must exist.
5656
//
@@ -59,12 +59,32 @@ type ClusterExtensionSpec struct {
5959
// and be no longer than 63 characters.
6060
//
6161
// [RFC 1123]: https://tools.ietf.org/html/rfc1123
62+
// </opcon:standard:description>
63+
// <opcon:experimental:description>
64+
// It designates the default namespace where namespace-scoped resources for the extension
65+
// are applied to.
66+
//
67+
// namespace is optional. When set, it must reference an existing namespace on the cluster.
68+
// When omitted, operator-controller resolves and creates a managed namespace from the
69+
// bundle's metadata. Whether namespace is set or omitted is fixed at creation time and
70+
// cannot be changed afterwards.
71+
//
72+
// The namespace field follows the DNS label standard as defined in [RFC 1123].
73+
// It must contain only lowercase alphanumeric characters or hyphens (-), start and end with an alphanumeric character,
74+
// and be no longer than 63 characters.
75+
//
76+
// [RFC 1123]: https://tools.ietf.org/html/rfc1123
77+
// </opcon:experimental:description>
78+
//
79+
// <opcon:standard:validation:XValidation:rule="self == oldSelf",message="namespace is immutable">
80+
// <opcon:standard:validation:XValidation:rule="self.matches("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")",message="namespace must be a valid DNS1123 label">
81+
// <opcon:experimental:validation:XValidation:rule="self == oldSelf",message="namespace is immutable">
82+
// <opcon:experimental:validation:XValidation:rule="self.matches("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")",message="namespace must be a valid DNS1123 label">
83+
// <opcon:experimental:validation:Optional>
6284
//
6385
// +kubebuilder:validation:MaxLength:=63
64-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="namespace is immutable"
65-
// +kubebuilder:validation:XValidation:rule="self.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$\")",message="namespace must be a valid DNS1123 label"
6686
// +required
67-
Namespace string `json:"namespace"`
87+
Namespace string `json:"namespace,omitzero"`
6888

6989
// serviceAccount is a deprecated field and is completely ignored.
7090
// OLMv1 is a single-tenant system where users with ClusterExtension write access are
@@ -586,6 +606,8 @@ type ClusterExtension struct {
586606
metav1.ObjectMeta `json:"metadata,omitempty"`
587607

588608
// spec is an optional field that defines the desired state of the ClusterExtension.
609+
//
610+
// <opcon:experimental:validation:XValidation:rule="has(oldSelf.namespace) == has(self.namespace)",message="namespace presence is immutable; it cannot be added or removed after creation">
589611
// +optional
590612
Spec ClusterExtensionSpec `json:"spec,omitempty"`
591613

‎applyconfigurations/api/v1/clusterextension.go‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎applyconfigurations/api/v1/clusterextensionspec.go‎

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)