Skip to content

Commit

Permalink
Report when backoff limit is exceeded
Browse files Browse the repository at this point in the history
Depends-On: openstack-k8s-operators/lib-common#504

Signed-off-by: Fabricio Aguiar <[email protected]>
  • Loading branch information
fao89 committed May 7, 2024
1 parent 3bb0a8b commit 1dfa222
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
3 changes: 3 additions & 0 deletions api/bases/ansibleee.openstack.org_openstackansibleees.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,9 @@ spec:
- type
type: object
type: array
failed:
format: int64
type: integer
hash:
additionalProperties:
type: string
Expand Down
4 changes: 4 additions & 0 deletions api/v1beta1/openstack_ansibleee_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ type OpenStackAnsibleEEStatus struct {
// JobStatus status of the executed job (Pending/Running/Succeeded/Failed)
JobStatus string `json:"JobStatus,omitempty" optional:"true"`

// The number of pods which reached phase Failed.
// +optional
Failed int32 `json:"failed,omitempty"`

// ObservedGeneration - the most recent generation observed for this
// service. If the observed generation is less than the spec generation,
// then the controller has not processed the latest changes injected by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,9 @@ spec:
- type
type: object
type: array
failed:
format: int64
type: integer
hash:
additionalProperties:
type: string
Expand Down
11 changes: 9 additions & 2 deletions controllers/openstack_ansibleee_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,20 @@ func (r *OpenStackAnsibleEEReconciler) Reconcile(ctx context.Context, req ctrl.R
}

if err != nil {
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
instance.Status.Failed = ansibleeeJob.GetTotalFailedAttempts()
return ctrl.Result{}, err
}

Expand Down
5 changes: 5 additions & 0 deletions docs/assemblies/openstack_ansibleee.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ OpenStackAnsibleEEStatus defines the observed state of OpenStackAnsibleEE
| string
| false
| failed
| The number of pods which reached phase Failed.
| int64
| false
| observedGeneration
| ObservedGeneration - the most recent generation observed for this service. If the observed generation is less than the spec generation, then the controller has not processed the latest changes injected by the opentack-operator in the top-level CR (e.g. the ContainerImage)
| int64
Expand Down
13 changes: 7 additions & 6 deletions tests/kuttl/tests/run_failed_playbook/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,18 @@ spec:
preserveJobs: true
status:
JobStatus: Failed
failed: 4
conditions:
- message: 'Job error occured Internal error occurred: Job Failed.
- message: 'Job error occured 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 occured Internal error occurred: Job Failed.
- message: 'Job error occured 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
---
Expand Down

0 comments on commit 1dfa222

Please sign in to comment.