From b0674d06d602468171f7bf5105a83bfcfef173e1 Mon Sep 17 00:00:00 2001 From: Fabricio Aguiar Date: Wed, 8 May 2024 13:52:32 +0100 Subject: [PATCH] Track retries and backoff limit Depends-On: https://github.com/openstack-k8s-operators/openstack-ansibleee-operator/pull/356 Signed-off-by: Fabricio Aguiar --- pkg/deployment/deployment.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/deployment/deployment.go b/pkg/deployment/deployment.go index 623822bfa..f782f950b 100644 --- a/pkg/deployment/deployment.go +++ b/pkg/deployment/deployment.go @@ -199,12 +199,21 @@ func (d *Deployer) ConditionalDeploy( } if ansibleEE.Status.JobStatus == ansibleeev1.JobStatusFailed { + severity := condition.SeverityWarning + errorReason := condition.ErrorReason + errorMsg := fmt.Sprintf("attempt #%d - execution.name %s execution.namespace %s execution.status.jobstatus: %s", ansibleEE.Status.failed, ansibleEE.Name, ansibleEE.Namespace, ansibleEE.Status.JobStatus) + ansibleCondition := ansibleEE.Status.Conditions.Get(condition.JobReadyCondition) + if ansibleCondition.Reason == condition.JobReasonBackoffLimitExceeded { + severity = condition.SeverityError + errorReason = condition.JobReasonBackoffLimitExceeded + errorMsg = fmt.Sprintf("backoff limit reached for execution.name %s execution.namespace %s execution.status.jobstatus: %s", ansibleEE.Name, ansibleEE.Namespace, ansibleEE.Status.JobStatus) + } log.Info(fmt.Sprintf("Condition %s error", readyCondition)) - err = fmt.Errorf("execution.name %s Execution.namespace %s Execution.status.jobstatus: %s", ansibleEE.Name, ansibleEE.Namespace, ansibleEE.Status.JobStatus) + err = fmt.Errorf(errorMsg) nsConditions.Set(condition.FalseCondition( readyCondition, - condition.ErrorReason, - condition.SeverityError, + errorReason, + severity, readyErrorMessage, err.Error())) }