From d9425cc29af34328f355b285726d1b18d0b044c7 Mon Sep 17 00:00:00 2001 From: Fabricio Aguiar Date: Tue, 28 May 2024 11:21:28 +0100 Subject: [PATCH] Report when backoff limit is exceeded Depends-On: https://github.com/openstack-k8s-operators/lib-common/pull/504 Signed-off-by: Fabricio Aguiar --- controllers/openstack_ansibleee_controller.go | 11 +++++++++-- tests/kuttl/tests/run_failed_playbook/01-assert.yaml | 8 ++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/controllers/openstack_ansibleee_controller.go b/controllers/openstack_ansibleee_controller.go index 0fa7b2c7..4209a52e 100644 --- a/controllers/openstack_ansibleee_controller.go +++ b/controllers/openstack_ansibleee_controller.go @@ -217,10 +217,17 @@ func (r *OpenStackAnsibleEEReconciler) Reconcile(ctx context.Context, req ctrl.R } if err != nil { + var errorReason condition.Reason + errorReason = condition.ErrorReason + severity := condition.SeverityWarning + if ansibleeeJob.HasReachedLimit() { + errorReason = condition.JobReasonBackoffLimitExceeded + severity = condition.SeverityError + } instance.Status.Conditions.Set(condition.FalseCondition( condition.JobReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, + errorReason, + severity, condition.JobReadyErrorMessage, err.Error())) instance.Status.JobStatus = ansibleeev1.JobStatusFailed diff --git a/tests/kuttl/tests/run_failed_playbook/01-assert.yaml b/tests/kuttl/tests/run_failed_playbook/01-assert.yaml index aaa34029..dff4fb05 100644 --- a/tests/kuttl/tests/run_failed_playbook/01-assert.yaml +++ b/tests/kuttl/tests/run_failed_playbook/01-assert.yaml @@ -26,14 +26,14 @@ status: conditions: - message: 'Job error occurred Internal error occurred: Job has reached the specified backoff limit. Check job logs' - reason: Error - severity: Warning + reason: BackoffLimitExceeded + severity: Error status: "False" type: Ready - message: 'Job error occurred Internal error occurred: Job has reached the specified backoff limit. Check job logs' - reason: Error - severity: Warning + reason: BackoffLimitExceeded + severity: Error status: "False" type: JobReady ---