Skip to content

Commit 38e96f2

Browse files
fix: CR has not error faced in the task (#2661)
Description of the change: - The reconcile was not marking the CR status when no event status is returned. Motivation for the change: - Closes #2565
1 parent 14e209e commit 38e96f2

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
- Fixed a regression in the `operator-sdk run` command that caused `--local` flags to be ignored ([#2478](https://github.com/operator-framework/operator-sdk/issues/2478))
4949
- Fix command `operator-sdk run --local` which was not working on Windows. ([#2481](https://github.com/operator-framework/operator-sdk/pull/2481))
5050
- Fix `ServiceMonitor` creation when the operator is cluster-scoped and the environment variable `WATCH_NAMESPACE` has a different value than the namespace where the operator is deployed. ([#2601](https://github.com/operator-framework/operator-sdk/pull/2601))
51+
- Fix missing error status when the error faced in the Ansible do not return an event status. ([#2661](https://github.com/operator-framework/operator-sdk/pull/2661))
5152

5253
## v0.15.2
5354

pkg/ansible/controller/reconcile.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ func (r *AnsibleOperatorReconciler) Reconcile(request reconcile.Request) (reconc
201201
eventErr := errors.New("did not receive playbook_on_stats event")
202202
stdout, err := result.Stdout()
203203
if err != nil {
204+
errmark := r.markError(u, request.NamespacedName, "Failed to get ansible-runner stdout")
205+
if errmark != nil {
206+
logger.Error(errmark, "Unable to mark error to run reconciliation")
207+
}
204208
logger.Error(err, "Failed to get ansible-runner stdout")
205209
return reconcileResult, err
206210
}

pkg/ansible/controller/reconcile_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,22 @@ func TestReconcile(t *testing.T) {
458458
"apiVersion": "operator-sdk/v1beta1",
459459
"kind": "Testing",
460460
"spec": map[string]interface{}{},
461+
"status": map[string]interface{}{
462+
"conditions": []interface{}{
463+
map[string]interface{}{
464+
"status": "True",
465+
"type": "Running",
466+
"ansibleResult": map[string]interface{}{
467+
"changed": int64(0),
468+
"failures": int64(0),
469+
"ok": int64(0),
470+
"skipped": int64(0),
471+
"completion": eventTime.Format("2006-01-02T15:04:05.99999999"),
472+
},
473+
"message": "Failed to get ansible-runner stdout",
474+
},
475+
},
476+
},
461477
},
462478
}),
463479
Result: reconcile.Result{

0 commit comments

Comments
 (0)