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 23, 2024
1 parent ef733f0 commit 36e59b4
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 18 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: int32
type: integer
hash:
additionalProperties:
type: string
Expand Down
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/go-playground/validator/v10 v10.19.0
github.com/onsi/ginkgo/v2 v2.18.0
github.com/onsi/gomega v1.33.1
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.20240523061957-78c308214ae3
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240429052447-09a614506ca6
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.28.9
Expand Down
4 changes: 2 additions & 2 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ github.com/onsi/ginkgo/v2 v2.18.0 h1:W9Y7IWXxPUpAit9ieMOLI7PJZGaW22DTKgiVAuhDTLc
github.com/onsi/ginkgo/v2 v2.18.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk=
github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0=
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.20240523061957-78c308214ae3 h1:0vrMw/RB4y8skUl/4u1h3mRNZ1iUXeh4ZcUjSQqnU8o=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240523061957-78c308214ae3/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
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: int32
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.
| int32
| 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.18.0
github.com/onsi/gomega v1.33.1
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.20240523061957-78c308214ae3
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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk=
github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0=
github.com/openshift/api v3.9.0+incompatible h1:fJ/KsefYuZAjmrr3+5U9yZIZbTOpVkDDLDLFresAeYs=
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.20240523061957-78c308214ae3 h1:0vrMw/RB4y8skUl/4u1h3mRNZ1iUXeh4ZcUjSQqnU8o=
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240523061957-78c308214ae3/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
8 changes: 4 additions & 4 deletions tests/functional/ansibleee_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ var _ = Describe("Ansibleee controller", func() {
condition.JobReadyCondition,
corev1.ConditionFalse,
condition.ErrorReason,
"Job error occurred Internal error occurred: Job Failed. Check job logs",
"Job error occurred Internal error occurred: Job Attempt #1 Failed. Check job logs",
)
th.ExpectCondition(
ansibleeeName,
Expand Down Expand Up @@ -261,7 +261,7 @@ var _ = Describe("Ansibleee controller", func() {
condition.JobReadyCondition,
corev1.ConditionFalse,
condition.ErrorReason,
"Job error occurred Internal error occurred: Job Failed. Check job logs",
"Job error occurred Internal error occurred: Job Attempt #1 Failed. Check job logs",
)
th.ExpectCondition(
ansibleeeName,
Expand Down Expand Up @@ -392,7 +392,7 @@ var _ = Describe("Ansibleee controller", func() {
condition.JobReadyCondition,
corev1.ConditionFalse,
condition.ErrorReason,
"Job error occurred Internal error occurred: Job Failed. Check job logs",
"Job error occurred Internal error occurred: Job Attempt #1 Failed. Check job logs",
)
th.ExpectCondition(
ansibleeeName,
Expand Down Expand Up @@ -540,7 +540,7 @@ var _ = Describe("Ansibleee controller", func() {
condition.JobReadyCondition,
corev1.ConditionFalse,
condition.ErrorReason,
"Job error occurred Internal error occurred: Job Failed. Check job logs",
"Job error occurred Internal error occurred: Job Attempt #1 Failed. Check job logs",
)
th.ExpectCondition(
ansibleeeName,
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 occurred Internal error occurred: Job Failed.
- 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 Failed.
- 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
---
Expand Down

0 comments on commit 36e59b4

Please sign in to comment.