Skip to content

Commit

Permalink
make status updates more readable and simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
pepov committed Sep 28, 2020
1 parent a5f7d40 commit ce3859f
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions pkg/reconciler/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,16 @@ func (r *Dispatcher) Handle(object runtime.Object) (ctrl.Result, error) {
combinedResult := &CombinedResult{}
for _, cr := range r.ComponentReconcilers {
if cr, ok := cr.(ComponentWithStatus); ok {
status := types.ReconcileStatusReconciling
if cr.IsSkipped(object) {
if uerr := cr.Update(object, types.ReconcileStatusUnmanaged, ""); uerr != nil {
combinedResult.CombineErr(errors.WrapIf(uerr, "unable to update status for component"))
}
continue
status = types.ReconcileStatusUnmanaged
}
if uerr := cr.Update(object, types.ReconcileStatusReconciling, ""); uerr != nil {
if uerr := cr.Update(object, status, ""); uerr != nil {
combinedResult.CombineErr(errors.WrapIf(uerr, "unable to update status for component"))
}
if cr.IsSkipped(object) {
continue
}
}
result, err := cr.Reconcile(object)
if cr, ok := cr.(ComponentWithStatus); ok {
Expand All @@ -106,14 +107,12 @@ func (r *Dispatcher) Handle(object runtime.Object) (ctrl.Result, error) {
}
} else {
if result == nil || (!result.Requeue && result.RequeueAfter == 0) {
status := types.ReconcileStatusRemoved
if cr.IsEnabled(object) {
if uerr := cr.Update(object, types.ReconcileStatusAvailable, ""); uerr != nil {
combinedResult.CombineErr(errors.WrapIf(uerr, "unable to update status for component"))
}
} else {
if uerr := cr.Update(object, types.ReconcileStatusRemoved, ""); uerr != nil {
combinedResult.CombineErr(errors.WrapIf(uerr, "unable to update status for component"))
}
status = types.ReconcileStatusAvailable
}
if uerr := cr.Update(object, status, ""); uerr != nil {
combinedResult.CombineErr(errors.WrapIf(uerr, "unable to update status for component"))
}
}
}
Expand Down

0 comments on commit ce3859f

Please sign in to comment.