Skip to content

Commit

Permalink
Track retries and backoff limit
Browse files Browse the repository at this point in the history
  • Loading branch information
fao89 committed May 9, 2024
1 parent 57cf568 commit 9bbeafd
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ spec:
type: string
ansibleTags:
type: string
backoffLimit:
default: 6
format: int32
type: integer
deploymentRequeueTime:
default: 15
minimum: 1
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta1/openstackdataplanedeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ type OpenStackDataPlaneDeploymentSpec struct {
// NodeSets is the list of NodeSets deployed
NodeSets []string `json:"nodeSets"`

// BackoffLimit allows to define the maximum number of retried executions (defaults to 6).
// +kubebuilder:default:=6
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number"}
BackoffLimit *int32 `json:"backoffLimit,omitempty"`

// AnsibleTags for ansible execution
// +kubebuilder:validation:Optional
AnsibleTags string `json:"ansibleTags,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ spec:
type: string
ansibleTags:
type: string
backoffLimit:
default: 6
format: int32
type: integer
deploymentRequeueTime:
default: 15
minimum: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ spec:
displayName: OpenStack Data Plane Deployments
kind: OpenStackDataPlaneDeployment
name: openstackdataplanedeployments.dataplane.openstack.org
specDescriptors:
- description: BackoffLimit allows to define the maximum number of retried executions
(defaults to 6).
displayName: Backoff Limit
path: backoffLimit
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:number
statusDescriptors:
- description: Conditions
displayName: Conditions
Expand Down Expand Up @@ -72,11 +79,6 @@ spec:
path: conditions
x-descriptors:
- urn:alm:descriptor:io.kubernetes.conditions
- description: Deployed
displayName: Deployed
path: deployed
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:booleanSwitch
version: v1beta1
- description: OpenStackDataPlaneService is the Schema for the openstackdataplaneservices
API OpenStackDataPlaneService name must be a valid RFC1123 as it is used in
Expand Down
5 changes: 5 additions & 0 deletions docs/assemblies/custom_resources.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,11 @@ OpenStackDataPlaneDeploymentSpec defines the desired state of OpenStackDataPlane
| []string
| true
| backoffLimit
| BackoffLimit allows to define the maximum number of retried executions (defaults to 6).
| *int32
| false
| ansibleTags
| AnsibleTags for ansible execution
| string
Expand Down
15 changes: 12 additions & 3 deletions pkg/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
Expand Down
1 change: 1 addition & 0 deletions pkg/util/ansible_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func AnsibleExecution(
if len(service.Spec.Playbook) > 0 {
ansibleEE.Spec.Playbook = service.Spec.Playbook
}
ansibleEE.Spec.BackoffLimit = deployment.Spec.BackoffLimit

// If we have a service that ought to be deployed everywhere
// substitute the existing play target with 'all'
Expand Down

0 comments on commit 9bbeafd

Please sign in to comment.