@@ -140,10 +140,10 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
140140 if err := c .establishWatch (ctx , rev , revision ); err != nil {
141141 werr := fmt .Errorf ("establish watch: %v" , err )
142142 // this error is very likely transient, so we should keep revision as progressing
143- rev . MarkAsProgressing ( ocv1 .ClusterExtensionRevisionReasonReconcileFailure , werr .Error ())
143+ markAsProgressing ( rev , ocv1 .ClusterExtensionRevisionReasonReconcileFailure , werr .Error ())
144144 return ctrl.Result {}, werr
145145 }
146- rev . MarkAsProgressing ( ocv1 .ClusterExtensionRevisionReasonRolloutInProgress , fmt .Sprintf ("Revision %s is being rolled out." , revVersion ))
146+ markAsProgressing ( rev , ocv1 .ClusterExtensionRevisionReasonRolloutInProgress , fmt .Sprintf ("Revision %s is being rolled out." , revVersion ))
147147 }
148148
149149 rres , err := c .RevisionEngine .Reconcile (ctx , * revision , opts ... )
@@ -154,7 +154,7 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
154154 l .Error (err , "revision reconcile failed" )
155155 }
156156 if inRollout {
157- rev . MarkAsProgressing ( ocv1 .ClusterExtensionRevisionReasonRolloutError , err .Error ())
157+ markAsProgressing ( rev , ocv1 .ClusterExtensionRevisionReasonRolloutError , err .Error ())
158158 } else {
159159 // it is a probably transient error, and we do not know if the revision is available or not
160160 // perhaps we should not report it at all, hoping that it is going to be mitigated in the next reconcile?
@@ -178,7 +178,7 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
178178
179179 if inRollout {
180180 // given that we retry, we are going to keep Progressing condition True
181- rev . MarkAsProgressing ( ocv1 .ClusterExtensionRevisionReasonRevisionValidationFailure , fmt .Sprintf ("revision validation error: %s" , verr ))
181+ markAsProgressing ( rev , ocv1 .ClusterExtensionRevisionReasonRevisionValidationFailure , fmt .Sprintf ("revision validation error: %s" , verr ))
182182 } else {
183183 // it is a probably transient error, and we do not know if the revision is available or not
184184 // perhaps we should not report it at all, hoping that it is going to be mitigated in the next reconcile?
@@ -199,7 +199,7 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
199199
200200 if inRollout {
201201 // given that we retry, we are going to keep Progressing condition True
202- rev . MarkAsProgressing ( ocv1 .ClusterExtensionRevisionReasonPhaseValidationError , fmt .Sprintf ("phase %d validation error: %s" , i , verr ))
202+ markAsProgressing ( rev , ocv1 .ClusterExtensionRevisionReasonPhaseValidationError , fmt .Sprintf ("phase %d validation error: %s" , i , verr ))
203203 } else {
204204 // it is a probably transient error, and we do not know if the revision is available or not
205205 // perhaps we should not report it at all, hoping that it is going to be mitigated in the next reconcile?
@@ -226,7 +226,7 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
226226 // collisions are probably stickier than phase roll out probe failures - so we'd probably want to set
227227 // Progressing to false here due to the collision
228228 if inRollout {
229- rev . MarkAsNotProgressing ( ocv1 .ClusterExtensionRevisionReasonObjectCollisions , fmt .Sprintf ("revision object collisions in phase %d\n %s" , i , strings .Join (collidingObjs , "\n \n " )))
229+ markAsNotProgressing ( rev , ocv1 .ClusterExtensionRevisionReasonObjectCollisions , fmt .Sprintf ("revision object collisions in phase %d\n %s" , i , strings .Join (collidingObjs , "\n \n " )))
230230
231231 // NOTE(pedjak): not sure if we want to retry here - collisions are probably not transient?
232232 return ctrl.Result {RequeueAfter : 10 * time .Second }, nil
@@ -236,7 +236,7 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
236236
237237 if ! rres .InTransistion () {
238238 // we have rolled out all objects in all phases, not interested in probes here
239- rev . MarkAsNotProgressing ( ocv1 .ClusterExtensionRevisionReasonRolledOut , fmt .Sprintf ("Revision %s is rolled out." , revVersion ))
239+ markAsNotProgressing ( rev , ocv1 .ClusterExtensionRevisionReasonRolledOut , fmt .Sprintf ("Revision %s is rolled out." , revVersion ))
240240 }
241241
242242 //nolint:nestif
@@ -254,7 +254,7 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
254254
255255 // It would be good to understand from Nico how we can distinguish between progression and availability probes
256256 // and how to best check that all Availability probes are passing
257- rev . MarkAsAvailable ( ocv1 .ClusterExtensionRevisionReasonProbesSucceeded , "Objects are available and pass all probes." )
257+ markAsAvailable ( rev , ocv1 .ClusterExtensionRevisionReasonProbesSucceeded , "Objects are available and pass all probes." )
258258
259259 // We'll probably only want to remove this once we are done updating the ClusterExtension conditions
260260 // as its one of the interfaces between the revision and the extension. If we still have the Succeeded for now
@@ -293,9 +293,9 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
293293 }
294294 }
295295 if len (probeFailureMsgs ) > 0 {
296- rev . MarkAsUnavailable ( ocv1 .ClusterExtensionRevisionReasonProbeFailure , strings .Join (probeFailureMsgs , "\n " ))
296+ markAsUnavailable ( rev , ocv1 .ClusterExtensionRevisionReasonProbeFailure , strings .Join (probeFailureMsgs , "\n " ))
297297 } else {
298- rev . MarkAsUnavailable ( ocv1 .ClusterExtensionRevisionReasonIncomplete , fmt .Sprintf ("Revision %s has not been rolled out completely." , revVersion ))
298+ markAsUnavailable ( rev , ocv1 .ClusterExtensionRevisionReasonIncomplete , fmt .Sprintf ("Revision %s has not been rolled out completely." , revVersion ))
299299 }
300300 }
301301
@@ -561,3 +561,43 @@ var (
561561 FieldB : ".status.replicas" ,
562562 }
563563)
564+
565+ func markAsProgressing (cer * ocv1.ClusterExtensionRevision , reason , message string ) {
566+ meta .SetStatusCondition (& cer .Status .Conditions , metav1.Condition {
567+ Type : ocv1 .ClusterExtensionRevisionTypeProgressing ,
568+ Status : metav1 .ConditionTrue ,
569+ Reason : reason ,
570+ Message : message ,
571+ ObservedGeneration : cer .Generation ,
572+ })
573+ }
574+
575+ func markAsNotProgressing (cer * ocv1.ClusterExtensionRevision , reason , message string ) {
576+ meta .SetStatusCondition (& cer .Status .Conditions , metav1.Condition {
577+ Type : ocv1 .ClusterExtensionRevisionTypeProgressing ,
578+ Status : metav1 .ConditionFalse ,
579+ Reason : reason ,
580+ Message : message ,
581+ ObservedGeneration : cer .Generation ,
582+ })
583+ }
584+
585+ func markAsAvailable (cer * ocv1.ClusterExtensionRevision , reason , message string ) {
586+ meta .SetStatusCondition (& cer .Status .Conditions , metav1.Condition {
587+ Type : ocv1 .ClusterExtensionRevisionTypeAvailable ,
588+ Status : metav1 .ConditionTrue ,
589+ Reason : reason ,
590+ Message : message ,
591+ ObservedGeneration : cer .Generation ,
592+ })
593+ }
594+
595+ func markAsUnavailable (cer * ocv1.ClusterExtensionRevision , reason , message string ) {
596+ meta .SetStatusCondition (& cer .Status .Conditions , metav1.Condition {
597+ Type : ocv1 .ClusterExtensionRevisionTypeAvailable ,
598+ Status : metav1 .ConditionFalse ,
599+ Reason : reason ,
600+ Message : message ,
601+ ObservedGeneration : cer .Generation ,
602+ })
603+ }
0 commit comments