diff --git a/controllers/glance_controller.go b/controllers/glance_controller.go index 4697ca47..8d19935e 100644 --- a/controllers/glance_controller.go +++ b/controllers/glance_controller.go @@ -137,11 +137,12 @@ func (r *GlanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res // Always patch the instance status when exiting this function so we can // persist any changes. defer func() { - // Always mirror the condition status (useful in case of failures) - instance.Status.Conditions.Set( - instance.Status.Conditions.Mirror(condition.ReadyCondition)) condition.RestoreLastTransitionTimes( &instance.Status.Conditions, savedConditions) + if instance.Status.Conditions.IsUnknown(condition.ReadyCondition) { + instance.Status.Conditions.Set( + instance.Status.Conditions.Mirror(condition.ReadyCondition)) + } err := helper.PatchInstance(ctx, instance) if err != nil { _err = err @@ -152,8 +153,11 @@ func (r *GlanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res // initialize conditions used later as Status=Unknown, except the ReadyCondition // that should be False when we start cl := condition.CreateList( - // Mark ReadyCondition as False from the beginning - condition.FalseCondition(condition.ReadyCondition, condition.InitReason, condition.SeverityInfo, condition.ReadyInitMessage), + // Mark ReadyCondition as Unknown from the beginning, because the + // Reconcile function is in progress. If this condition is not marked + // as True and is still in the "Unknown" state, we `Mirror(` the actual + // failure + condition.UnknownCondition(condition.ReadyCondition, condition.InitReason, condition.ReadyInitMessage), condition.UnknownCondition(condition.DBReadyCondition, condition.InitReason, condition.DBReadyInitMessage), condition.UnknownCondition(condition.DBSyncReadyCondition, condition.InitReason, condition.DBSyncReadyInitMessage), condition.UnknownCondition(condition.MemcachedReadyCondition, condition.InitReason, condition.MemcachedReadyInitMessage), diff --git a/controllers/glanceapi_controller.go b/controllers/glanceapi_controller.go index e9f338a3..e39792a4 100644 --- a/controllers/glanceapi_controller.go +++ b/controllers/glanceapi_controller.go @@ -134,9 +134,12 @@ func (r *GlanceAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( // Always patch the instance status when exiting this function so we can persist any changes. defer func() { - // Always mirror the Condition from the sub level CRs - instance.Status.Conditions.Set(instance.Status.Conditions.Mirror(condition.ReadyCondition)) - condition.RestoreLastTransitionTimes(&instance.Status.Conditions, savedConditions) + condition.RestoreLastTransitionTimes( + &instance.Status.Conditions, savedConditions) + if instance.Status.Conditions.IsUnknown(condition.ReadyCondition) { + instance.Status.Conditions.Set( + instance.Status.Conditions.Mirror(condition.ReadyCondition)) + } err := helper.PatchInstance(ctx, instance) if err != nil { _err = err @@ -146,6 +149,11 @@ func (r *GlanceAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( // initialize conditions used later as Status=Unknown cl := condition.CreateList( + // Mark ReadyCondition as Unknown from the beginning, because the + // Reconcile function is in progress. If this condition is not marked + // as True and is still in the "Unknown" state, we `Mirror(` the actual + // failure + condition.UnknownCondition(condition.ReadyCondition, condition.InitReason, condition.ReadyInitMessage), condition.UnknownCondition(glancev1.CinderCondition, condition.InitReason, glancev1.CinderInitMessage), condition.UnknownCondition(condition.ExposeServiceReadyCondition, condition.InitReason, condition.ExposeServiceReadyInitMessage), condition.UnknownCondition(condition.InputReadyCondition, condition.InitReason, condition.InputReadyInitMessage),