Skip to content

Commit 8d747c8

Browse files
author
Per Goncalves da Silva
committed
On refactor/cer-ready-condition: WIP: combined changes for reference
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
2 parents 28102fa + 11144fd commit 8d747c8

22 files changed

+1052
-700
lines changed

api/v1/clusterextension_types.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,16 +436,14 @@ type CRDUpgradeSafetyPreflightConfig struct {
436436
}
437437

438438
const (
439-
// TypeDeprecated is a rollup condition that is present when
440-
// any of the deprecated conditions are present.
439+
// Deprecation Condition Types
441440
TypeDeprecated = "Deprecated"
442441
TypePackageDeprecated = "PackageDeprecated"
443442
TypeChannelDeprecated = "ChannelDeprecated"
444443
TypeBundleDeprecated = "BundleDeprecated"
445444

446-
// None will not perform CRD upgrade safety checks.
447-
CRDUpgradeSafetyEnforcementNone CRDUpgradeSafetyEnforcement = "None"
448-
// Strict will enforce the CRD upgrade safety check and block the upgrade if the CRD would not pass the check.
445+
// CRD Upgrade Safety Enforcement
446+
CRDUpgradeSafetyEnforcementNone CRDUpgradeSafetyEnforcement = "None"
449447
CRDUpgradeSafetyEnforcementStrict CRDUpgradeSafetyEnforcement = "Strict"
450448
)
451449

api/v1/clusterextensionrevision_types.go

Lines changed: 94 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,18 @@ const (
2525
ClusterExtensionRevisionKind = "ClusterExtensionRevision"
2626

2727
// Condition Types
28-
ClusterExtensionRevisionTypeAvailable = "Available"
29-
ClusterExtensionRevisionTypeProgressing = "Progressing"
30-
ClusterExtensionRevisionTypeSucceeded = "Succeeded"
28+
ClusterExtensionRevisionTypeReady = "Ready"
3129

3230
// Condition Reasons
33-
ClusterExtensionRevisionReasonArchived = "Archived"
34-
ClusterExtensionRevisionReasonBlocked = "Blocked"
35-
ClusterExtensionRevisionReasonProbeFailure = "ProbeFailure"
36-
ClusterExtensionRevisionReasonProbesSucceeded = "ProbesSucceeded"
37-
ClusterExtensionRevisionReasonReconciling = "Reconciling"
38-
ClusterExtensionRevisionReasonRetrying = "Retrying"
31+
ClusterExtensionRevisionReasonReady = "Ready"
32+
ClusterExtensionRevisionReasonReconciling = "Reconciling"
33+
ClusterExtensionRevisionReasonProbeFailure = "ProbeFailure"
34+
ClusterExtensionRevisionReasonValidationFailed = "ValidationFailed"
35+
ClusterExtensionRevisionReasonObjectCollision = "ObjectCollision"
36+
ClusterExtensionRevisionReasonProgressDeadlineExceeded = "ProgressDeadlineExceeded"
37+
ClusterExtensionRevisionReasonArchived = "Archived"
38+
ClusterExtensionRevisionReasonRollingOut = "RollingOut"
39+
ClusterExtensionRevisionReasonTransitioning = "Transitioning"
3940
)
4041

4142
// ClusterExtensionRevisionSpec defines the desired state of ClusterExtensionRevision.
@@ -87,17 +88,6 @@ type ClusterExtensionRevisionSpec struct {
8788
// +listMapKey=name
8889
// +optional
8990
Phases []ClusterExtensionRevisionPhase `json:"phases,omitempty"`
90-
91-
// progressDeadlineMinutes is an optional field that defines the maximum period
92-
// of time in minutes after which an installation should be considered failed and
93-
// require manual intervention. This functionality is disabled when no value
94-
// is provided. The minimum period is 10 minutes, and the maximum is 720 minutes (12 hours).
95-
//
96-
// +kubebuilder:validation:Minimum:=10
97-
// +kubebuilder:validation:Maximum:=720
98-
// +optional
99-
// <opcon:experimental>
100-
ProgressDeadlineMinutes int32 `json:"progressDeadlineMinutes,omitempty"`
10191
}
10292

10393
// ClusterExtensionRevisionLifecycleState specifies the lifecycle state of the ClusterExtensionRevision.
@@ -184,39 +174,106 @@ const (
184174
CollisionProtectionNone CollisionProtection = "None"
185175
)
186176

177+
// ClusterExtensionRevisionPhaseState represents the state of a phase during rollout.
178+
type ClusterExtensionRevisionPhaseState string
179+
180+
const (
181+
// ClusterExtensionRevisionPhaseStateApplied indicates all objects in the phase have been successfully applied.
182+
ClusterExtensionRevisionPhaseStateApplied ClusterExtensionRevisionPhaseState = "Applied"
183+
// ClusterExtensionRevisionPhaseStateProgressing indicates the phase is actively being reconciled and probes are being evaluated.
184+
ClusterExtensionRevisionPhaseStateProgressing ClusterExtensionRevisionPhaseState = "Progressing"
185+
// ClusterExtensionRevisionPhaseStateFailed indicates the phase has failed due to validation errors or collisions.
186+
ClusterExtensionRevisionPhaseStateFailed ClusterExtensionRevisionPhaseState = "Failed"
187+
// ClusterExtensionRevisionPhaseStatePending indicates the phase is waiting for previous phases to complete.
188+
ClusterExtensionRevisionPhaseStatePending ClusterExtensionRevisionPhaseState = "Pending"
189+
// ClusterExtensionRevisionPhaseStateTransitioning indicates objects in the phase are transitioning to a newer revision.
190+
ClusterExtensionRevisionPhaseStateTransitioning ClusterExtensionRevisionPhaseState = "Transitioning"
191+
)
192+
193+
// ClusterExtensionRevisionProbeFailure describes a failing probe for an object in a phase.
194+
type ClusterExtensionRevisionProbeFailure struct {
195+
// kind is the Kind of the object failing probes.
196+
// +required
197+
Kind string `json:"kind"`
198+
199+
// name is the name of the object failing probes.
200+
// +required
201+
Name string `json:"name"`
202+
203+
// namespace is the namespace of the object failing probes.
204+
// Empty for cluster-scoped objects.
205+
// +optional
206+
Namespace string `json:"namespace,omitempty"`
207+
208+
// message contains the joined probe failure messages.
209+
// +required
210+
Message string `json:"message"`
211+
}
212+
213+
// ClusterExtensionRevisionPhaseStatus describes the status of a single phase.
214+
type ClusterExtensionRevisionPhaseStatus struct {
215+
// name is the name of the phase.
216+
// +required
217+
Name string `json:"name"`
218+
219+
// state represents the current state of the phase.
220+
// +required
221+
// +kubebuilder:validation:Enum=Applied;Progressing;Failed;Pending;Transitioning
222+
State ClusterExtensionRevisionPhaseState `json:"state"`
223+
224+
// message provides additional context about the phase state.
225+
// This may include error messages for failed phases.
226+
// +optional
227+
Message string `json:"message,omitempty"`
228+
229+
// lastTransitionTime is the last time the phase state changed.
230+
// This only updates when the state, message, or failingProbes change.
231+
// +required
232+
LastTransitionTime metav1.Time `json:"lastTransitionTime"`
233+
234+
// failingProbes lists objects in this phase that are failing their readiness probes.
235+
// Only populated when state is Progressing and probes are failing.
236+
// +optional
237+
// +listType=atomic
238+
FailingProbes []ClusterExtensionRevisionProbeFailure `json:"failingProbes,omitempty"`
239+
}
240+
187241
// ClusterExtensionRevisionStatus defines the observed state of a ClusterExtensionRevision.
188242
type ClusterExtensionRevisionStatus struct {
189243
// conditions is an optional list of status conditions describing the state of the
190244
// ClusterExtensionRevision.
191245
//
192-
// The Progressing condition represents whether the revision is actively rolling out:
193-
// - When status is True and reason is RollingOut, the ClusterExtensionRevision rollout is actively making progress and is in transition.
194-
// - When status is True and reason is Retrying, the ClusterExtensionRevision has encountered an error that could be resolved on subsequent reconciliation attempts.
195-
// - When status is True and reason is Succeeded, the ClusterExtensionRevision has reached the desired state.
196-
// - When status is False and reason is Blocked, the ClusterExtensionRevision has encountered an error that requires manual intervention for recovery.
246+
// The Ready condition represents whether the revision has been successfully rolled out and is ready:
247+
// - When status is True and reason is Ready, all ClusterExtensionRevision resources have been applied and all progression probes are successful.
248+
// - When status is False and reason is RollingOut, the ClusterExtensionRevision rollout is actively making progress and objects are being applied.
249+
// - When status is False and reason is Reconciling, the ClusterExtensionRevision is being reconciled or retrying after an error.
250+
// - When status is False and reason is ProbeFailure, one or more objects are failing their readiness probes.
251+
// - When status is False and reason is ValidationFailed, the revision failed preflight validation checks.
252+
// - When status is False and reason is ObjectCollision, the revision encountered object ownership collisions.
253+
// - When status is False and reason is ProgressDeadlineExceeded, the revision has not completed within the specified progress deadline.
254+
// - When status is False and reason is Transitioning, the revision's objects are being transitioned to a newer revision.
197255
// - When status is False and reason is Archived, the ClusterExtensionRevision is archived and not being actively reconciled.
198256
//
199-
// The Available condition represents whether the revision has been successfully rolled out and is available:
200-
// - When status is True and reason is ProbesSucceeded, the ClusterExtensionRevision has been successfully rolled out and all objects pass their readiness probes.
201-
// - When status is False and reason is ProbeFailure, one or more objects are failing their readiness probes during rollout.
202-
// - When status is Unknown and reason is Reconciling, the ClusterExtensionRevision has encountered an error that prevented it from observing the probes.
203-
// - When status is Unknown and reason is Archived, the ClusterExtensionRevision has been archived and its objects have been torn down.
204-
// - When status is Unknown and reason is Migrated, the ClusterExtensionRevision was migrated from an existing release and object status probe results have not yet been observed.
205-
//
206-
// The Succeeded condition represents whether the revision has successfully completed its rollout:
207-
// - When status is True and reason is Succeeded, the ClusterExtensionRevision has successfully completed its rollout. This condition is set once and persists even if the revision later becomes unavailable.
208-
//
209257
// +listType=map
210258
// +listMapKey=type
211259
// +optional
212260
Conditions []metav1.Condition `json:"conditions,omitempty"`
261+
262+
// phaseStatuses provides detailed status information for each phase in the revision.
263+
// Each phase status includes the phase name, current state, any error messages,
264+
// and details about failing probes if applicable.
265+
//
266+
// +listType=map
267+
// +listMapKey=name
268+
// +optional
269+
PhaseStatuses []ClusterExtensionRevisionPhaseStatus `json:"phaseStatuses,omitempty"`
213270
}
214271

215272
// +kubebuilder:object:root=true
216273
// +kubebuilder:resource:scope=Cluster
217274
// +kubebuilder:subresource:status
218-
// +kubebuilder:printcolumn:name="Available",type=string,JSONPath=`.status.conditions[?(@.type=='Available')].status`
219-
// +kubebuilder:printcolumn:name="Progressing",type=string,JSONPath=`.status.conditions[?(@.type=='Progressing')].status`
275+
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=='Ready')].status`
276+
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=='Ready')].reason`
220277
// +kubebuilder:printcolumn:name=Age,type=date,JSONPath=`.metadata.creationTimestamp`
221278

222279
// ClusterExtensionRevision represents an immutable snapshot of Kubernetes objects

api/v1/validation_test.go

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -88,52 +88,6 @@ func TestValidate(t *testing.T) {
8888
},
8989
want: want{valid: true},
9090
},
91-
"ClusterExtensionRevision: invalid progress deadline < 10": {
92-
args: args{
93-
object: ClusterExtensionRevisionSpec{
94-
ProgressDeadlineMinutes: 9,
95-
},
96-
},
97-
want: want{valid: false},
98-
},
99-
"ClusterExtensionRevision: valid progress deadline = 10": {
100-
args: args{
101-
object: ClusterExtensionRevisionSpec{
102-
ProgressDeadlineMinutes: 10,
103-
},
104-
},
105-
want: want{valid: true},
106-
},
107-
"ClusterExtensionRevision: valid progress deadline = 360": {
108-
args: args{
109-
object: ClusterExtensionRevisionSpec{
110-
ProgressDeadlineMinutes: 360,
111-
},
112-
},
113-
want: want{valid: true},
114-
},
115-
"ClusterExtensionRevision: valid progress deadline = 720": {
116-
args: args{
117-
object: ClusterExtensionRevisionSpec{
118-
ProgressDeadlineMinutes: 720,
119-
},
120-
},
121-
want: want{valid: true},
122-
},
123-
"ClusterExtensionRevision: invalid progress deadline > 720": {
124-
args: args{
125-
object: ClusterExtensionRevisionSpec{
126-
ProgressDeadlineMinutes: 721,
127-
},
128-
},
129-
want: want{valid: false},
130-
},
131-
"ClusterExtensionRevision: no progress deadline set": {
132-
args: args{
133-
object: ClusterExtensionRevisionSpec{},
134-
},
135-
want: want{valid: true},
136-
},
13791
} {
13892
t.Run(name, func(t *testing.T) {
13993
var obj client.Object

api/v1/zz_generated.deepcopy.go

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

cmd/operator-controller/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ func (c *boxcutterReconcilerConfigurator) Configure(ceReconciler *controllers.Cl
632632
controllers.ResolveBundle(c.resolver, c.mgr.GetClient()),
633633
controllers.UnpackBundle(c.imagePuller, c.imageCache),
634634
controllers.ApplyBundleWithBoxcutter(appl.Apply),
635+
controllers.CheckProgressDeadline(&ceReconciler.ProgressDeadlineCheckInFlight),
635636
}
636637

637638
baseDiscoveryClient, err := discovery.NewDiscoveryClientForConfig(c.mgr.GetConfig())
@@ -751,6 +752,7 @@ func (c *helmReconcilerConfigurator) Configure(ceReconciler *controllers.Cluster
751752
controllers.ResolveBundle(c.resolver, c.mgr.GetClient()),
752753
controllers.UnpackBundle(c.imagePuller, c.imageCache),
753754
controllers.ApplyBundle(appl),
755+
controllers.CheckProgressDeadline(&ceReconciler.ProgressDeadlineCheckInFlight),
754756
}
755757

756758
return nil

0 commit comments

Comments
 (0)