Skip to content

Commit

Permalink
Merge pull request #496 from fmount/mirror_conditions
Browse files Browse the repository at this point in the history
Mirror ReadyCondition with the actual current condition
  • Loading branch information
openshift-merge-bot[bot] authored Apr 1, 2024
2 parents bd1b51e + 6e9b0d9 commit 8fe440e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 9 additions & 5 deletions controllers/glance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,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
Expand All @@ -153,8 +154,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),
Expand Down
14 changes: 11 additions & 3 deletions controllers/glanceapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,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
Expand All @@ -147,6 +150,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),
Expand Down

0 comments on commit 8fe440e

Please sign in to comment.