Skip to content

Commit 2aaa6e1

Browse files
committed
Track failure per nodeset
A failed service job (backoff limit exceeded) stalls whole deployment and reconcile returned before the other nodeSets could be advanced, so their in-flight jobs were never collected and their remaining services never started. InitConditions() wipes NodeSetConditions every pass and the AEE job backing the failure is garbage collected once its TTL expires, so once it is gone the failure can no longer be derived. Signed-off-by: Rabi Mishra <ramishra@redhat.com>
1 parent 4d7ca3a commit 2aaa6e1

7 files changed

Lines changed: 298 additions & 26 deletions

File tree

‎api/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ spec:
236236
deployedVersion:
237237
description: DeployedVersion
238238
type: string
239+
failedNodeSets:
240+
additionalProperties:
241+
type: string
242+
description: |-
243+
FailedNodeSets maps a nodeSet name to the message of the permanent failure
244+
that terminated it. Terminality cannot live in the conditions because the AEE
245+
job backing the failure is garbage collected once the deployment settles.
246+
type: object
239247
nodeSetConditions:
240248
additionalProperties:
241249
description: Conditions provide observations of the operational

‎api/dataplane/v1beta1/openstackdataplanedeployment_types.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ type OpenStackDataPlaneDeploymentStatus struct {
112112
// NodeSetConditions
113113
NodeSetConditions map[string]condition.Conditions `json:"nodeSetConditions,omitempty" optional:"true"`
114114

115+
// FailedNodeSets maps a nodeSet name to the message of the permanent failure
116+
// that terminated it. Terminality cannot live in the conditions because the AEE
117+
// job backing the failure is garbage collected once the deployment settles.
118+
FailedNodeSets map[string]string `json:"failedNodeSets,omitempty" optional:"true"`
119+
115120
// AnsibleEEHashes
116121
AnsibleEEHashes map[string]string `json:"ansibleEEHashes,omitempty" optional:"true"`
117122

‎api/dataplane/v1beta1/zz_generated.deepcopy.go‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bindata/crds/crds.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20863,6 +20863,14 @@ spec:
2086320863
deployedVersion:
2086420864
description: DeployedVersion
2086520865
type: string
20866+
failedNodeSets:
20867+
additionalProperties:
20868+
type: string
20869+
description: |-
20870+
FailedNodeSets maps a nodeSet name to the message of the permanent failure
20871+
that terminated it. Terminality cannot live in the conditions because the AEE
20872+
job backing the failure is garbage collected once the deployment settles.
20873+
type: object
2086620874
nodeSetConditions:
2086720875
additionalProperties:
2086820876
description: Conditions provide observations of the operational

‎config/crd/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ spec:
236236
deployedVersion:
237237
description: DeployedVersion
238238
type: string
239+
failedNodeSets:
240+
additionalProperties:
241+
type: string
242+
description: |-
243+
FailedNodeSets maps a nodeSet name to the message of the permanent failure
244+
that terminated it. Terminality cannot live in the conditions because the AEE
245+
job backing the failure is garbage collected once the deployment settles.
246+
type: object
239247
nodeSetConditions:
240248
additionalProperties:
241249
description: Conditions provide observations of the operational

‎internal/controller/dataplane/openstackdataplanedeployment_controller.go‎

Lines changed: 69 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,10 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
113113
return ctrl.Result{}, nil
114114
}
115115

116-
// If the deployment has failed with backoff limit exceeded, do not reconcile
117-
// even if nodesets or other watched resources change. The deployment is in a
118-
// terminal failure state and should not be retried.
119-
if instance.Status.Conditions != nil {
120-
deploymentCondition := instance.Status.Conditions.Get(condition.DeploymentReadyCondition)
121-
if deploymentCondition != nil &&
122-
deploymentCondition.Severity == condition.SeverityError &&
123-
deploymentCondition.Reason == condition.JobReasonBackoffLimitExceeded {
124-
Log.Info("Deployment has failed with backoff limit exceeded, skipping reconciliation",
125-
"deployment", instance.Name)
126-
return ctrl.Result{}, nil
127-
}
116+
if terminalFailure(instance) {
117+
Log.Info("Deployment is terminal, skipping reconciliation",
118+
"deployment", instance.Name)
119+
return ctrl.Result{}, nil
128120
}
129121

130122
// initialize status if Conditions is nil, but do not reset if it already
@@ -255,7 +247,10 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
255247
haveError := false
256248
deploymentErrMsg := ""
257249
var servicePlan *deployment.ServicePlan
258-
backoffLimitReached := false
250+
var finishedNodeSets []dataplanev1.OpenStackDataPlaneNodeSet
251+
if instance.Status.FailedNodeSets == nil {
252+
instance.Status.FailedNodeSets = map[string]string{}
253+
}
259254

260255
if servicePlan, err = deployment.DedupeServices(ctx, helper, nodeSets.Items,
261256
instance.Spec.ServicesOverride); err != nil {
@@ -383,6 +378,21 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
383378
for i := range nodeSets.Items {
384379
nodeSet := &nodeSets.Items[i]
385380

381+
if failure, ok := instance.Status.FailedNodeSets[nodeSet.Name]; ok {
382+
Log.Info("NodeSet already terminated by a permanent failure", "nodeSet", nodeSet.Name)
383+
nsConditions := instance.Status.NodeSetConditions[nodeSet.Name]
384+
nsConditions.MarkFalse(
385+
dataplanev1.NodeSetDeploymentReadyCondition,
386+
condition.JobReasonBackoffLimitExceeded,
387+
condition.SeverityError,
388+
"%s", failure)
389+
instance.Status.NodeSetConditions[nodeSet.Name] = nsConditions
390+
haveError = true
391+
deploymentErrMsg = appendDeploymentErrMsg(deploymentErrMsg,
392+
fmt.Sprintf("nodeSet: %s error: %s", nodeSet.Name, failure))
393+
continue
394+
}
395+
386396
Log.Info("Deploying NodeSet", "nodeSet", nodeSet.Name)
387397
Log.Info("Set Status.Deployed to false", "instance", instance)
388398
instance.Status.Deployed = false
@@ -413,14 +423,12 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
413423
util.LogErrorForObject(helper, err, fmt.Sprintf("OpenStackDeployment error for NodeSet %s", nodeSet.Name), instance)
414424
Log.Info("Set NodeSetDeploymentReadyCondition false", "nodeSet", nodeSet.Name)
415425
haveError = true
416-
errMsg := fmt.Sprintf("nodeSet: %s error: %s", nodeSet.Name, err.Error())
417-
if len(deploymentErrMsg) == 0 {
418-
deploymentErrMsg = errMsg
419-
} else {
420-
deploymentErrMsg = fmt.Sprintf("%s & %s", deploymentErrMsg, errMsg)
426+
deploymentErrMsg = appendDeploymentErrMsg(deploymentErrMsg,
427+
fmt.Sprintf("nodeSet: %s error: %s", nodeSet.Name, err.Error()))
428+
if nsConditions.Get(dataplanev1.NodeSetDeploymentReadyCondition) != nil &&
429+
nsConditions.Get(dataplanev1.NodeSetDeploymentReadyCondition).Reason == condition.JobReasonBackoffLimitExceeded {
430+
instance.Status.FailedNodeSets[nodeSet.Name] = err.Error()
421431
}
422-
errorReason := nsConditions.Get(dataplanev1.NodeSetDeploymentReadyCondition).Reason
423-
backoffLimitReached = errorReason == condition.JobReasonBackoffLimitExceeded
424432
}
425433

426434
if deployResult != nil {
@@ -433,14 +441,26 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
433441
condition.DeploymentReadyMessage)
434442
instance.Status.NodeSetHashes[nodeSet.Name] = nodeSet.Status.ConfigHash
435443
instance.Status.BmhRefHashes[nodeSet.Name] = nodeSet.Status.BmhRefHash
444+
finishedNodeSets = append(finishedNodeSets, *nodeSet)
445+
}
446+
}
447+
448+
// A nodeSet that finished alongside a failure must still get its hashes, or the
449+
// NodeSet controller re-deploys it because its inputs look changed.
450+
if len(finishedNodeSets) > 0 {
451+
err = r.setHashes(ctx, helper, instance,
452+
dataplanev1.OpenStackDataPlaneNodeSetList{Items: finishedNodeSets})
453+
if err != nil {
454+
Log.Error(err, "Error setting service hashes")
436455
}
437456
}
438457

439458
if haveError {
459+
settled := terminalFailure(instance)
440460
var reason condition.Reason
441461
reason = condition.ErrorReason
442462
severity := condition.SeverityWarning
443-
if backoffLimitReached {
463+
if settled {
444464
reason = condition.JobReasonBackoffLimitExceeded
445465
severity = condition.SeverityError
446466
}
@@ -450,7 +470,7 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
450470
severity,
451471
condition.DeploymentReadyErrorMessage,
452472
deploymentErrMsg)
453-
if backoffLimitReached {
473+
if settled {
454474
return ctrl.Result{}, nil
455475
}
456476
return ctrl.Result{}, fmt.Errorf("%s", deploymentErrMsg)
@@ -468,10 +488,6 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
468488
if version != nil {
469489
instance.Status.DeployedVersion = version.Spec.TargetVersion
470490
}
471-
err = r.setHashes(ctx, helper, instance, *nodeSets)
472-
if err != nil {
473-
Log.Error(err, "Error setting service hashes")
474-
}
475491
return ctrl.Result{}, nil
476492
}
477493

@@ -703,6 +719,33 @@ func (r *OpenStackDataPlaneDeploymentReconciler) listNodeSets(ctx context.Contex
703719
return &nodeSets, err
704720
}
705721

722+
// terminalFailure reports whether the deployment has a permanently failed
723+
// nodeSet and nothing left to wait for. A nodeSet still in flight keeps this
724+
// false even when another one already failed.
725+
func terminalFailure(instance *dataplanev1.OpenStackDataPlaneDeployment) bool {
726+
if len(instance.Spec.NodeSets) == 0 || len(instance.Status.FailedNodeSets) == 0 {
727+
return false
728+
}
729+
for _, nodeSet := range instance.Spec.NodeSets {
730+
if _, failed := instance.Status.FailedNodeSets[nodeSet]; failed {
731+
continue
732+
}
733+
nsConditions := instance.Status.NodeSetConditions[nodeSet]
734+
nsCondition := nsConditions.Get(dataplanev1.NodeSetDeploymentReadyCondition)
735+
if nsCondition == nil || nsCondition.Status != corev1.ConditionTrue {
736+
return false
737+
}
738+
}
739+
return true
740+
}
741+
742+
func appendDeploymentErrMsg(current string, errMsg string) string {
743+
if len(current) == 0 {
744+
return errMsg
745+
}
746+
return fmt.Sprintf("%s & %s", current, errMsg)
747+
}
748+
706749
func setNodeSetAnsibleVarsFromHashes(
707750
ctx context.Context,
708751
helper *helper.Helper,

0 commit comments

Comments
 (0)