Skip to content

Commit

Permalink
Expose the backoff limit
Browse files Browse the repository at this point in the history
  • Loading branch information
fao89 committed May 28, 2024
1 parent 9f05094 commit 5d42463
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 3 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 @@ -30,6 +30,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 @@ -20,6 +20,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
5 changes: 5 additions & 0 deletions docs/assemblies/custom_resources.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,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
11 changes: 8 additions & 3 deletions pkg/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,17 @@ func (d *Deployer) ConditionalDeploy(
}

if ansibleEE.Status.JobStatus == ansibleeev1.JobStatusFailed {
errorMsg := fmt.Sprintf("execution.name %s execution.namespace %s execution.status.jobstatus: %s", ansibleEE.Name, ansibleEE.Namespace, ansibleEE.Status.JobStatus)
ansibleCondition := ansibleEE.Status.Conditions.Get(condition.JobReadyCondition)
if ansibleCondition.Reason == 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,
ansibleCondition.Reason,
ansibleCondition.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 5d42463

Please sign in to comment.