Skip to content

Commit 2fa7c55

Browse files
author
Per Goncalves da Silva
committed
Update ClusterExtensionRevision API docs
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
1 parent 5ed8cf4 commit 2fa7c55

File tree

4 files changed

+493
-86
lines changed

4 files changed

+493
-86
lines changed

api/v1/clusterextensionrevision_types.go

Lines changed: 133 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ import (
2424
const (
2525
ClusterExtensionRevisionKind = "ClusterExtensionRevision"
2626

27-
// Condition Types
27+
// ClusterExtensionRevisionTypeAvailable is the condition type that represents whether the
28+
// ClusterExtensionRevision is available and has been successfully rolled out.
2829
ClusterExtensionRevisionTypeAvailable = "Available"
30+
31+
// ClusterExtensionRevisionTypeSucceeded is the condition type that represents whether the
32+
// ClusterExtensionRevision rollout has succeeded at least once.
2933
ClusterExtensionRevisionTypeSucceeded = "Succeeded"
3034

31-
// Condition Reasons
35+
// Condition reasons
3236
ClusterExtensionRevisionReasonAvailable = "Available"
3337
ClusterExtensionRevisionReasonReconcileFailure = "ReconcileFailure"
3438
ClusterExtensionRevisionReasonRevisionValidationFailure = "RevisionValidationFailure"
@@ -43,23 +47,54 @@ const (
4347
)
4448

4549
// ClusterExtensionRevisionSpec defines the desired state of ClusterExtensionRevision.
50+
//
51+
// A ClusterExtensionRevision represents a specific immutable snapshot of the objects
52+
// to be installed for a ClusterExtension. Each revision is rolled out in phases,
53+
// with objects organized by their Group-Kind into well-known phases such as namespaces,
54+
// rbac, crds, and deploy.
4655
type ClusterExtensionRevisionSpec struct {
47-
// Specifies the lifecycle state of the ClusterExtensionRevision.
56+
// The lifecycleState field specifies the lifecycle state of the ClusterExtensionRevision.
57+
//
58+
// When set to "Active" (the default), the revision is actively managed and reconciled.
59+
// When set to "Paused", reconciliation is disabled but status updates continue.
60+
// When set to "Archived", the revision is torn down and scaled to zero.
61+
// The revision is removed from the owner list of all objects previously under management.
62+
// All objects that did not transition to a succeeding revision are deleted.
63+
//
64+
// Once a revision is set to "Archived", it cannot be un-archived.
4865
//
4966
// +kubebuilder:default="Active"
5067
// +kubebuilder:validation:Enum=Active;Paused;Archived
5168
// +kubebuilder:validation:XValidation:rule="oldSelf == 'Active' || oldSelf == 'Paused' || oldSelf == 'Archived' && oldSelf == self", message="can not un-archive"
5269
LifecycleState ClusterExtensionRevisionLifecycleState `json:"lifecycleState,omitempty"`
53-
// Revision is a sequence number representing a specific revision of the ClusterExtension instance.
54-
// Must be positive. Each ClusterExtensionRevision of the same parent ClusterExtension needs to have
55-
// a unique value assigned. It is immutable after creation. The new revision number must always be previous revision +1.
70+
71+
// The revision field is a required, immutable sequence number representing a specific revision
72+
// of the parent ClusterExtension.
73+
//
74+
// The revision field must be a positive integer.
75+
// Each ClusterExtensionRevision belonging to the same parent ClusterExtension must have a unique revision number.
76+
// The revision number must always be the previous revision number plus one, or 1 for the first revision.
5677
//
5778
// +kubebuilder:validation:Required
5879
// +kubebuilder:validation:Minimum:=1
5980
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="revision is immutable"
6081
Revision int64 `json:"revision"`
61-
// Phases are groups of objects that will be applied at the same time.
62-
// All objects in the phase will have to pass their probes in order to progress to the next phase.
82+
83+
// The phases field is an optional, immutable list of phases that group objects to be applied together.
84+
//
85+
// Objects are organized into phases based on their Group-Kind. Common phases include:
86+
// - namespaces: Namespace objects
87+
// - policies: ResourceQuota, LimitRange, NetworkPolicy objects
88+
// - rbac: ServiceAccount, Role, RoleBinding, ClusterRole, ClusterRoleBinding objects
89+
// - crds: CustomResourceDefinition objects
90+
// - storage: PersistentVolume, PersistentVolumeClaim, StorageClass objects
91+
// - deploy: Deployment, StatefulSet, DaemonSet, Service, ConfigMap, Secret objects
92+
// - publish: Ingress, APIService, Route, Webhook objects
93+
//
94+
// All objects in a phase are applied simultaneously.
95+
// The revision progresses to the next phase only after all objects in the current phase pass their readiness probes.
96+
//
97+
// Once set (even if empty), the phases field is immutable.
6398
//
6499
// +kubebuilder:validation:XValidation:rule="self == oldSelf || oldSelf.size() == 0", message="phases is immutable"
65100
// +listType=map
@@ -75,33 +110,68 @@ const (
75110
// ClusterExtensionRevisionLifecycleStateActive / "Active" is the default lifecycle state.
76111
ClusterExtensionRevisionLifecycleStateActive ClusterExtensionRevisionLifecycleState = "Active"
77112
// ClusterExtensionRevisionLifecycleStatePaused / "Paused" disables reconciliation of the ClusterExtensionRevision.
78-
// Only Status updates will still propagated, but object changes will not be reconciled.
113+
// Object changes will not be reconciled. However, status updates will be propagated.
79114
ClusterExtensionRevisionLifecycleStatePaused ClusterExtensionRevisionLifecycleState = "Paused"
80-
// ClusterExtensionRevisionLifecycleStateArchived / "Archived" disables reconciliation while also "scaling to zero",
81-
// which deletes all objects that are not excluded via the pausedFor property and
82-
// removes itself from the owner list of all other objects previously under management.
115+
// ClusterExtensionRevisionLifecycleStateArchived / "Archived" archives the revision for historical or auditing purposes.
116+
// The revision is removed from the owner list of all other objects previously under management and all objects
117+
// that did not transition to a succeeding revision are deleted.
83118
ClusterExtensionRevisionLifecycleStateArchived ClusterExtensionRevisionLifecycleState = "Archived"
84119
)
85120

86-
// ClusterExtensionRevisionPhase are groups of objects that will be applied at the same time.
87-
// All objects in the a phase will have to pass their probes in order to progress to the next phase.
121+
// ClusterExtensionRevisionPhase represents a group of objects that are applied together.
122+
//
123+
// Objects in a phase are applied simultaneously.
124+
// All objects must pass their readiness probes before the revision progresses to the next phase.
125+
// Phases are applied in a defined order based on the types of objects they contain.
88126
type ClusterExtensionRevisionPhase struct {
89-
// Name identifies this phase.
127+
// The name field is a required identifier for this phase.
128+
//
129+
// Phase names must follow the DNS label standard as defined in [RFC 1123].
130+
// They must contain only lowercase alphanumeric characters or hyphens (-),
131+
// start and end with an alphanumeric character, and be no longer than 63 characters.
132+
//
133+
// Common phase names include: namespaces, policies, rbac, crds, storage, deploy, publish.
134+
//
135+
// [RFC 1123]: https://tools.ietf.org/html/rfc1123
90136
//
91137
// +kubebuilder:validation:MaxLength=63
92138
// +kubebuilder:validation:Pattern=`^[a-z]([-a-z0-9]*[a-z0-9])?$`
93139
Name string `json:"name"`
94-
// Objects are a list of all the objects within this phase.
140+
141+
// The objects field is a required list of all Kubernetes objects in this phase.
142+
//
143+
// All objects in this list are applied to the cluster simultaneously.
144+
// The phase is considered complete only after all objects pass their readiness probes.
95145
Objects []ClusterExtensionRevisionObject `json:"objects"`
96146
}
97147

98-
// ClusterExtensionRevisionObject contains an object and settings for it.
148+
// ClusterExtensionRevisionObject represents a Kubernetes object to be applied as part
149+
// of a ClusterExtensionRevision, along with its collision protection settings.
99150
type ClusterExtensionRevisionObject struct {
151+
// The object field is a required embedded Kubernetes object to be applied.
152+
//
153+
// This object must be a valid Kubernetes resource with apiVersion, kind, and metadata fields.
154+
// Status fields are not permitted and are removed if present.
155+
// Only specific metadata fields are preserved: name, namespace, labels, and annotations.
156+
//
100157
// +kubebuilder:validation:EmbeddedResource
101158
// +kubebuilder:pruning:PreserveUnknownFields
102159
Object unstructured.Unstructured `json:"object"`
103-
// CollisionProtection controls whether OLM can adopt and modify objects
104-
// already existing on the cluster or even owned by another controller.
160+
161+
// The collisionProtection field controls whether the operator can adopt and modify objects
162+
// that already exist on the cluster.
163+
//
164+
// When set to "Prevent" (the default), the operator only manages objects it created itself.
165+
// This prevents ownership collisions.
166+
//
167+
// When set to "IfNoController", the operator can adopt and modify pre-existing objects
168+
// that are not owned by another controller.
169+
// This is useful for taking over management of manually-created resources.
170+
//
171+
// When set to "None", the operator can adopt and modify any pre-existing object, even if
172+
// owned by another controller.
173+
// Use this setting with extreme caution as it may cause multiple controllers to fight over
174+
// the same resource, resulting in increased load on the API server and etcd.
105175
//
106176
// +kubebuilder:default="Prevent"
107177
// +kubebuilder:validation:Enum=Prevent;IfNoController;None
@@ -128,6 +198,27 @@ const (
128198

129199
// ClusterExtensionRevisionStatus defines the observed state of a ClusterExtensionRevision.
130200
type ClusterExtensionRevisionStatus struct {
201+
// conditions is an optional list of status conditions describing the state of the
202+
// ClusterExtensionRevision.
203+
//
204+
// The Progressing condition represents whether the revision is actively rolling out:
205+
// - When status is True and reason is Progressing, the revision rollout is actively making progress and is in transition.
206+
// - When Progressing is not present, the revision is not currently in transition.
207+
//
208+
// The Available condition represents whether the revision has been successfully rolled out and is available:
209+
// - When status is True and reason is Available, the revision has been successfully rolled out and all objects pass their readiness probes.
210+
// - When status is False and reason is Incomplete, the revision rollout has not yet completed but no specific failures have been detected.
211+
// - When status is False and reason is ProbeFailure, one or more objects are failing their readiness probes during rollout.
212+
// - When status is False and reason is ReconcileFailure, the revision has encountered a general reconciliation failure.
213+
// - When status is False and reason is RevisionValidationFailure, the revision failed preflight validation checks.
214+
// - When status is False and reason is PhaseValidationError, a phase within the revision failed preflight validation checks.
215+
// - When status is False and reason is ObjectCollisions, objects in the revision collide with existing cluster objects that cannot be adopted.
216+
// - When status is Unknown and reason is Archived, the revision has been archived and its objects have been torn down.
217+
// - When status is Unknown and reason is Migrated, the revision was migrated from an existing release and object status probe results have not yet been observed.
218+
//
219+
// The Succeeded condition represents whether the revision has successfully completed its rollout at least once:
220+
// - When status is True and reason is RolloutSuccess, the revision has successfully completed its rollout. This condition is set once and persists even if the revision later becomes unavailable.
221+
//
131222
// +listType=map
132223
// +listMapKey=type
133224
// +optional
@@ -137,19 +228,38 @@ type ClusterExtensionRevisionStatus struct {
137228
// +kubebuilder:object:root=true
138229
// +kubebuilder:resource:scope=Cluster
139230
// +kubebuilder:subresource:status
140-
141-
// ClusterExtensionRevision is the Schema for the clusterextensionrevisions API
142231
// +kubebuilder:printcolumn:name="Available",type=string,JSONPath=`.status.conditions[?(@.type=='Available')].status`
143232
// +kubebuilder:printcolumn:name=Age,type=date,JSONPath=`.metadata.creationTimestamp`
233+
234+
// ClusterExtensionRevision is the schema for the ClusterExtensionRevisions API.
235+
//
236+
// A ClusterExtensionRevision represents an immutable snapshot of Kubernetes objects
237+
// for a specific version of a ClusterExtension. Each revision contains objects
238+
// organized into phases that roll out sequentially.
239+
//
240+
// The ClusterExtension controller creates and manages ClusterExtensionRevisions automatically.
241+
// Do not create them directly. Each ClusterExtension can have multiple revisions as it
242+
// upgrades or reconfigures.
243+
//
244+
// The revision rollout uses a phased approach where objects apply in a defined order based
245+
// on type (for example: namespaces, then RBAC, then CRDs, then deployments). All objects
246+
// in a phase apply simultaneously and must pass readiness probes before rollout continues
247+
// to the next phase.
248+
//
249+
// Revisions have three lifecycle states:
250+
// - Active: The revision is actively managed and reconciled (default)
251+
// - Paused: Reconciliation is disabled but status updates continue
252+
// - Archived: The revision is torn down, objects are deleted, and the revision removes
253+
// itself from the owner list of managed objects
144254
type ClusterExtensionRevision struct {
145255
metav1.TypeMeta `json:",inline"`
146256
metav1.ObjectMeta `json:"metadata,omitempty"`
147257

148-
// spec is an optional field that defines the desired state of the ClusterExtension.
258+
// The spec field is optional and defines the desired state of the ClusterExtensionRevision.
149259
// +optional
150260
Spec ClusterExtensionRevisionSpec `json:"spec,omitempty"`
151261

152-
// status is an optional field that defines the observed state of the ClusterExtension.
262+
// The status field is optional and defines the observed state of the ClusterExtensionRevision.
153263
// +optional
154264
Status ClusterExtensionRevisionStatus `json:"status,omitempty"`
155265
}

0 commit comments

Comments
 (0)