Skip to content

Commit 09d0d70

Browse files
author
Shawn Hurley
authored
pkg/ansible: Update the running condition when reconcile happens (#1066)
**Description of the change:** * will alert the user to when reconcile is happening * will show the user the last results from ansible * handles the case when the operator is failing. **Motivation for the change:** Better messaging to users when things are happening.
1 parent 1d3aa60 commit 09d0d70

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

pkg/ansible/controller/reconcile.go

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ func (r *AnsibleOperatorReconciler) Reconcile(request reconcile.Request) (reconc
198198
if exit, err := determineReturn(err); exit {
199199
return reconcileResult, err
200200
}
201-
return reconcileResult, nil
202201
}
203202
if r.ManageStatus {
204203
err = r.markDone(u, request.NamespacedName, statusEvent, failureMessages)
@@ -218,26 +217,26 @@ func (r *AnsibleOperatorReconciler) markRunning(u *unstructured.Unstructured, na
218217

219218
// If there is no current status add that we are working on this resource.
220219
errCond := ansiblestatus.GetCondition(crStatus, ansiblestatus.FailureConditionType)
221-
succCond := ansiblestatus.GetCondition(crStatus, ansiblestatus.RunningConditionType)
222220

221+
if errCond != nil {
222+
errCond.Status = v1.ConditionFalse
223+
ansiblestatus.SetCondition(&crStatus, *errCond)
224+
}
223225
// If the condition is currently running, making sure that the values are correct.
224226
// If they are the same a no-op, if they are different then it is a good thing we
225227
// are updating it.
226-
if (errCond == nil && succCond == nil) || (succCond != nil && succCond.Reason != ansiblestatus.SuccessfulReason) {
227-
c := ansiblestatus.NewCondition(
228-
ansiblestatus.RunningConditionType,
229-
v1.ConditionTrue,
230-
nil,
231-
ansiblestatus.RunningReason,
232-
ansiblestatus.RunningMessage,
233-
)
234-
ansiblestatus.SetCondition(&crStatus, *c)
235-
u.Object["status"] = crStatus.GetJSONMap()
236-
err := r.Client.Status().Update(context.TODO(), u)
237-
if err != nil {
238-
return err
239-
}
240-
228+
c := ansiblestatus.NewCondition(
229+
ansiblestatus.RunningConditionType,
230+
v1.ConditionTrue,
231+
nil,
232+
ansiblestatus.RunningReason,
233+
ansiblestatus.RunningMessage,
234+
)
235+
ansiblestatus.SetCondition(&crStatus, *c)
236+
u.Object["status"] = crStatus.GetJSONMap()
237+
err := r.Client.Status().Update(context.TODO(), u)
238+
if err != nil {
239+
return err
241240
}
242241
return nil
243242
}

0 commit comments

Comments
 (0)