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 22, 2024
1 parent 881da6f commit 62e2602
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 9 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
12 changes: 10 additions & 2 deletions controllers/openstack_ansibleee_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,21 @@ 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
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.4.0
github.com/onsi/ginkgo/v2 v2.17.2
github.com/onsi/gomega v1.33.0
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240429052447-09a614506ca6
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240522141801-d6e03083e82a
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240429052447-09a614506ca6
github.com/openstack-k8s-operators/openstack-ansibleee-operator/api v0.0.0-00010101000000-000000000000
gopkg.in/yaml.v3 v3.0.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ github.com/openshift/api v3.9.0+incompatible h1:fJ/KsefYuZAjmrr3+5U9yZIZbTOpVkDD
github.com/openshift/api v3.9.0+incompatible/go.mod h1:dh9o4Fs58gpFXGSYfnVxGR9PnV53I8TW84pQaJDdGiY=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240429052447-09a614506ca6 h1:WLsG3Ko+phW5xZJjncypLWGASoLqKrt05qN9Zxsad6g=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240429052447-09a614506ca6/go.mod h1:lYhFzul37AR/6gAhTAA1KKWbOlzB3F/7014lejn883c=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240522141801-d6e03083e82a h1:kcASVA9sZg9DtggyJlN6JZE6pIenJgXivFK6ry7WUVM=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240522141801-d6e03083e82a/go.mod h1:lYhFzul37AR/6gAhTAA1KKWbOlzB3F/7014lejn883c=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240429052447-09a614506ca6 h1:NNSOEpTZCa9RL5sZiF4ZOlB+agBrL7q7FB9pC58d4S8=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240429052447-09a614506ca6/go.mod h1:C/qUWW4lW3687riZxYd+YRCtOyHZKURu3Imv6S9OP7U=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
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 62e2602

Please sign in to comment.