@@ -131,7 +131,10 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
131131 return ctrl.Result {}, fmt .Errorf ("error ensuring teardown finalizer: %v" , err )
132132 }
133133
134- // If the Available condition is not present, we are still rolling out the objects
134+ // If the Available condition is not present, we are still rolling out the objects.
135+ // NOTE: This assumes that once the Available condition is set, it will always be present.
136+ // If the Available condition is ever removed or reset during the lifecycle,
137+ // this could lead to incorrect behavior.
135138 inRollout := meta .FindStatusCondition (rev .Status .Conditions , ocv1 .ClusterExtensionRevisionTypeAvailable ) == nil
136139 if inRollout {
137140 if err := c .establishWatch (ctx , rev , revision ); err != nil {
@@ -339,17 +342,26 @@ func (c *ClusterExtensionRevisionReconciler) teardown(ctx context.Context, rev *
339342 return ctrl.Result {}, fmt .Errorf ("error stopping informers: %v" , err )
340343 }
341344
342- // Ensure Available condition is set to Unknown before removing the finalizer when archiving
343- if rev .Spec .LifecycleState == ocv1 .ClusterExtensionRevisionLifecycleStateArchived &&
344- ! meta .IsStatusConditionPresentAndEqual (rev .Status .Conditions , ocv1 .ClusterExtensionRevisionTypeAvailable , metav1 .ConditionUnknown ) {
345- meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
345+ // Ensure conditions are set before removing the finalizer when archiving
346+ if rev .Spec .LifecycleState == ocv1 .ClusterExtensionRevisionLifecycleStateArchived {
347+ condUpdated := meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
346348 Type : ocv1 .ClusterExtensionRevisionTypeAvailable ,
347349 Status : metav1 .ConditionUnknown ,
348350 Reason : ocv1 .ClusterExtensionRevisionReasonArchived ,
349351 Message : "revision is archived" ,
350352 ObservedGeneration : rev .Generation ,
351353 })
352- return ctrl.Result {}, nil
354+ condUpdated = meta .SetStatusCondition (& rev .Status .Conditions , metav1.Condition {
355+ Type : ocv1 .ClusterExtensionRevisionTypeProgressing ,
356+ Status : metav1 .ConditionFalse ,
357+ Reason : ocv1 .ClusterExtensionRevisionReasonArchived ,
358+ Message : "revision is archived" ,
359+ ObservedGeneration : rev .Generation ,
360+ }) || condUpdated
361+
362+ if condUpdated {
363+ return ctrl.Result {}, nil
364+ }
353365 }
354366
355367 if err := c .removeFinalizer (ctx , rev , clusterExtensionRevisionTeardownFinalizer ); err != nil {
0 commit comments