diff --git a/api/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml b/api/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml index 306445ece..e1cea05f8 100644 --- a/api/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml +++ b/api/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml @@ -52,6 +52,10 @@ spec: type: string ansibleTags: type: string + backoffLimit: + default: 6 + format: int32 + type: integer deploymentRequeueTime: default: 15 minimum: 1 diff --git a/api/v1beta1/openstackdataplanedeployment_types.go b/api/v1beta1/openstackdataplanedeployment_types.go index f97a72165..d5b318399 100644 --- a/api/v1beta1/openstackdataplanedeployment_types.go +++ b/api/v1beta1/openstackdataplanedeployment_types.go @@ -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"` diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 882eb9e20..236e3e56e 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -294,6 +294,11 @@ func (in *OpenStackDataPlaneDeploymentSpec) DeepCopyInto(out *OpenStackDataPlane *out = make([]string, len(*in)) copy(*out, *in) } + if in.BackoffLimit != nil { + in, out := &in.BackoffLimit, &out.BackoffLimit + *out = new(int32) + **out = **in + } if in.AnsibleExtraVars != nil { in, out := &in.AnsibleExtraVars, &out.AnsibleExtraVars *out = make(map[string]json.RawMessage, len(*in)) diff --git a/config/crd/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml b/config/crd/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml index 306445ece..e1cea05f8 100644 --- a/config/crd/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml +++ b/config/crd/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml @@ -52,6 +52,10 @@ spec: type: string ansibleTags: type: string + backoffLimit: + default: 6 + format: int32 + type: integer deploymentRequeueTime: default: 15 minimum: 1 diff --git a/config/manifests/bases/dataplane-operator.clusterserviceversion.yaml b/config/manifests/bases/dataplane-operator.clusterserviceversion.yaml index 174841b23..bb793b810 100644 --- a/config/manifests/bases/dataplane-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/dataplane-operator.clusterserviceversion.yaml @@ -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 diff --git a/docs/assemblies/custom_resources.adoc b/docs/assemblies/custom_resources.adoc index 52404ffcf..125c97843 100644 --- a/docs/assemblies/custom_resources.adoc +++ b/docs/assemblies/custom_resources.adoc @@ -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 diff --git a/pkg/deployment/deployment.go b/pkg/deployment/deployment.go index 6a85f9cdb..1866cffdd 100644 --- a/pkg/deployment/deployment.go +++ b/pkg/deployment/deployment.go @@ -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())) } diff --git a/pkg/util/ansible_execution.go b/pkg/util/ansible_execution.go index 4fd8902df..6672d47bb 100644 --- a/pkg/util/ansible_execution.go +++ b/pkg/util/ansible_execution.go @@ -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'