@@ -129,26 +129,16 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
129129 return ctrl.Result {}, fmt .Errorf ("error ensuring teardown finalizer: %v" , err )
130130 }
131131
132+ // If the Available condition is not present, we are still rolling out the objects
132133 inRollout := meta .FindStatusCondition (rev .Status .Conditions , ocv1 .ClusterExtensionRevisionTypeAvailable ) == nil
133134 if inRollout {
134135 if err := c .establishWatch (ctx , rev , revision ); err != nil {
135136 werr := fmt .Errorf ("establish watch: %v" , err )
136- meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
137- Type : ocv1 .ClusterExtensionRevisionTypeProgressing ,
138- Status : metav1 .ConditionTrue ,
139- Reason : ocv1 .ClusterExtensionRevisionReasonReconcileFailure ,
140- Message : werr .Error (),
141- ObservedGeneration : rev .Generation ,
142- })
137+ // this error is very likely transient, so we should keep revision as progressing
138+ rev .MarkAsProgressing (ocv1 .ClusterExtensionRevisionReasonReconcileFailure , werr .Error ())
143139 return ctrl.Result {}, werr
144140 }
145- meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
146- Type : ocv1 .ClusterExtensionRevisionTypeProgressing ,
147- Status : metav1 .ConditionTrue ,
148- Reason : ocv1 .ClusterExtensionRevisionReasonRolloutInProgress ,
149- Message : "Revision is being rolled out." ,
150- ObservedGeneration : rev .Generation ,
151- })
141+ rev .MarkAsProgressing (ocv1 .ClusterExtensionRevisionReasonRolloutInProgress , "Revision is being rolled out." )
152142 }
153143
154144 rres , err := c .RevisionEngine .Reconcile (ctx , * revision , opts ... )
@@ -159,15 +149,10 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
159149 l .Error (err , "revision reconcile failed" )
160150 }
161151 if inRollout {
162- meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
163- Type : ocv1 .ClusterExtensionRevisionTypeProgressing ,
164- Status : metav1 .ConditionTrue ,
165- Reason : ocv1 .ClusterExtensionRevisionReasonRolloutError ,
166- Message : err .Error (),
167- ObservedGeneration : rev .Generation ,
168- })
152+ rev .MarkAsProgressing (ocv1 .ClusterExtensionRevisionReasonRolloutError , err .Error ())
169153 } else {
170154 // it is a probably transient error, and we do not know if the revision is available or not
155+ // perhaps we should not report it at all, hoping that it is going to be mitigated in the next reconcile?
171156 meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
172157 Type : ocv1 .ClusterExtensionRevisionTypeAvailable ,
173158 Status : metav1 .ConditionUnknown ,
@@ -187,16 +172,11 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
187172 l .Error (fmt .Errorf ("%w" , verr ), "preflight validation failed, retrying after 10s" )
188173
189174 if inRollout {
190- // given that we retry, we are not going to keep Progressing condition True
191- meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
192- Type : ocv1 .ClusterExtensionRevisionTypeProgressing ,
193- Status : metav1 .ConditionTrue ,
194- Reason : ocv1 .ClusterExtensionRevisionReasonRevisionValidationFailure ,
195- Message : fmt .Sprintf ("revision validation error: %s" , verr ),
196- ObservedGeneration : rev .Generation ,
197- })
175+ // given that we retry, we are going to keep Progressing condition True
176+ rev .MarkAsProgressing (ocv1 .ClusterExtensionRevisionReasonRevisionValidationFailure , fmt .Sprintf ("revision validation error: %s" , verr ))
198177 } else {
199178 // it is a probably transient error, and we do not know if the revision is available or not
179+ // perhaps we should not report it at all, hoping that it is going to be mitigated in the next reconcile?
200180 meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
201181 Type : ocv1 .ClusterExtensionRevisionTypeAvailable ,
202182 Status : metav1 .ConditionUnknown ,
@@ -213,16 +193,11 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
213193 l .Error (fmt .Errorf ("%w" , verr ), "phase preflight validation failed, retrying after 10s" , "phase" , i )
214194
215195 if inRollout {
216- // given that we retry, we are not going to keep Progressing condition True
217- meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
218- Type : ocv1 .ClusterExtensionRevisionTypeProgressing ,
219- Status : metav1 .ConditionTrue ,
220- Reason : ocv1 .ClusterExtensionRevisionReasonPhaseValidationError ,
221- Message : fmt .Sprintf ("phase %d validation error: %s" , i , verr ),
222- ObservedGeneration : rev .Generation ,
223- })
196+ // given that we retry, we are going to keep Progressing condition True
197+ rev .MarkAsProgressing (ocv1 .ClusterExtensionRevisionReasonPhaseValidationError , fmt .Sprintf ("phase %d validation error: %s" , i , verr ))
224198 } else {
225199 // it is a probably transient error, and we do not know if the revision is available or not
200+ // perhaps we should not report it at all, hoping that it is going to be mitigated in the next reconcile?
226201 meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
227202 Type : ocv1 .ClusterExtensionRevisionTypeAvailable ,
228203 Status : metav1 .ConditionUnknown ,
@@ -246,29 +221,17 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
246221 // collisions are probably stickier than phase roll out probe failures - so we'd probably want to set
247222 // Progressing to false here due to the collision
248223 if inRollout {
249- meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
250- Type : ocv1 .ClusterExtensionRevisionTypeProgressing ,
251- Status : metav1 .ConditionFalse ,
252- Reason : ocv1 .ClusterExtensionRevisionReasonObjectCollisions ,
253- Message : fmt .Sprintf ("revision object collisions in phase %d\n %s" , i , strings .Join (collidingObjs , "\n \n " )),
254- ObservedGeneration : rev .Generation ,
255- })
224+ rev .MarkAsNotProgressing (ocv1 .ClusterExtensionRevisionReasonObjectCollisions , fmt .Sprintf ("revision object collisions in phase %d\n %s" , i , strings .Join (collidingObjs , "\n \n " )))
256225
257- // not sure if we want to retry here - collisions are probably not transient?
226+ // NOTE(pedjak): not sure if we want to retry here - collisions are probably not transient?
258227 return ctrl.Result {RequeueAfter : 10 * time .Second }, nil
259228 }
260229 }
261230 }
262231
263232 if ! rres .InTransistion () {
264233 // we have rolled out all objects in all phases, not interested in probes here
265- meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
266- Type : ocv1 .ClusterExtensionRevisionTypeProgressing ,
267- Status : metav1 .ConditionFalse ,
268- Reason : ocv1 .ClusterExtensionRevisionReasonRolledOut ,
269- Message : "Revision is rolled out." ,
270- ObservedGeneration : rev .Generation ,
271- })
234+ rev .MarkAsNotProgressing (ocv1 .ClusterExtensionRevisionReasonRolledOut , "Revision is rolled out." )
272235 }
273236
274237 //nolint:nestif
@@ -286,13 +249,7 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
286249
287250 // It would be good to understand from Nico how we can distinguish between progression and availability probes
288251 // and how to best check that all Availability probes are passing
289- meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
290- Type : ocv1 .ClusterExtensionRevisionTypeAvailable ,
291- Status : metav1 .ConditionTrue ,
292- Reason : ocv1 .ClusterExtensionRevisionReasonAvailable ,
293- Message : "Objects are available and passes all probes." ,
294- ObservedGeneration : rev .Generation ,
295- })
252+ rev .MarkAsAvailable (ocv1 .ClusterExtensionRevisionReasonProbesSucceeded , "Objects are available and pass all probes." )
296253
297254 // We'll probably only want to remove this once we are done updating the ClusterExtension conditions
298255 // as its one of the interfaces between the revision and the extension. If we still have the Succeeded for now
@@ -331,21 +288,9 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
331288 }
332289 }
333290 if len (probeFailureMsgs ) > 0 {
334- meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
335- Type : ocv1 .ClusterExtensionRevisionTypeAvailable ,
336- Status : metav1 .ConditionFalse ,
337- Reason : ocv1 .ClusterExtensionRevisionReasonProbeFailure ,
338- Message : strings .Join (probeFailureMsgs , "\n " ),
339- ObservedGeneration : rev .Generation ,
340- })
291+ rev .MarkAsUnavailable (ocv1 .ClusterExtensionRevisionReasonProbeFailure , strings .Join (probeFailureMsgs , "\n " ))
341292 } else {
342- meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
343- Type : ocv1 .ClusterExtensionRevisionTypeAvailable ,
344- Status : metav1 .ConditionFalse ,
345- Reason : ocv1 .ClusterExtensionRevisionReasonIncomplete ,
346- Message : "Revision has not been rolled out completely." ,
347- ObservedGeneration : rev .Generation ,
348- })
293+ rev .MarkAsUnavailable (ocv1 .ClusterExtensionRevisionReasonIncomplete , "Revision has not been rolled out completely." )
349294 }
350295 }
351296
0 commit comments