Skip to content

Commit 328843a

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 b703e9c commit 328843a

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
@@ -112,18 +112,10 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
112112
return ctrl.Result{}, nil
113113
}
114114

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

129121
// 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
deploymentErrMsg := ""
256248
var nodesetServiceMap map[string][]string
257249
var serviceCache *deployment.ServiceCache
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 nodesetServiceMap, serviceCache, err = deployment.DedupeServices(ctx, helper, nodeSets.Items,
261256
instance.Spec.ServicesOverride); err != nil {
@@ -313,6 +308,21 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
313308
}
314309
for _, nodeSet := range nodeSets.Items {
315310

311+
if failure, ok := instance.Status.FailedNodeSets[nodeSet.Name]; ok {
312+
Log.Info("NodeSet already terminated by a permanent failure", "nodeSet", nodeSet.Name)
313+
nsConditions := instance.Status.NodeSetConditions[nodeSet.Name]
314+
nsConditions.MarkFalse(
315+
dataplanev1.NodeSetDeploymentReadyCondition,
316+
condition.JobReasonBackoffLimitExceeded,
317+
condition.SeverityError,
318+
"%s", failure)
319+
instance.Status.NodeSetConditions[nodeSet.Name] = nsConditions
320+
haveError = true
321+
deploymentErrMsg = appendDeploymentErrMsg(deploymentErrMsg,
322+
fmt.Sprintf("nodeSet: %s error: %s", nodeSet.Name, failure))
323+
continue
324+
}
325+
316326
Log.Info("Deploying NodeSet", "nodeSet", nodeSet.Name)
317327
Log.Info("Set Status.Deployed to false", "instance", instance)
318328
instance.Status.Deployed = false
@@ -383,14 +393,12 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
383393
util.LogErrorForObject(helper, err, fmt.Sprintf("OpenStackDeployment error for NodeSet %s", nodeSet.Name), instance)
384394
Log.Info("Set NodeSetDeploymentReadyCondition false", "nodeSet", nodeSet.Name)
385395
haveError = true
386-
errMsg := fmt.Sprintf("nodeSet: %s error: %s", nodeSet.Name, err.Error())
387-
if len(deploymentErrMsg) == 0 {
388-
deploymentErrMsg = errMsg
389-
} else {
390-
deploymentErrMsg = fmt.Sprintf("%s & %s", deploymentErrMsg, errMsg)
396+
deploymentErrMsg = appendDeploymentErrMsg(deploymentErrMsg,
397+
fmt.Sprintf("nodeSet: %s error: %s", nodeSet.Name, err.Error()))
398+
if nsConditions.Get(dataplanev1.NodeSetDeploymentReadyCondition) != nil &&
399+
nsConditions.Get(dataplanev1.NodeSetDeploymentReadyCondition).Reason == condition.JobReasonBackoffLimitExceeded {
400+
instance.Status.FailedNodeSets[nodeSet.Name] = err.Error()
391401
}
392-
errorReason := nsConditions.Get(dataplanev1.NodeSetDeploymentReadyCondition).Reason
393-
backoffLimitReached = errorReason == condition.JobReasonBackoffLimitExceeded
394402
}
395403

396404
if deployResult != nil {
@@ -403,14 +411,26 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
403411
condition.DeploymentReadyMessage)
404412
instance.Status.NodeSetHashes[nodeSet.Name] = nodeSet.Status.ConfigHash
405413
instance.Status.BmhRefHashes[nodeSet.Name] = nodeSet.Status.BmhRefHash
414+
finishedNodeSets = append(finishedNodeSets, nodeSet)
415+
}
416+
}
417+
418+
// A nodeSet that finished alongside a failure must still get its hashes, or the
419+
// NodeSet controller re-deploys it because its inputs look changed.
420+
if len(finishedNodeSets) > 0 {
421+
err = r.setHashes(ctx, helper, instance,
422+
dataplanev1.OpenStackDataPlaneNodeSetList{Items: finishedNodeSets})
423+
if err != nil {
424+
Log.Error(err, "Error setting service hashes")
406425
}
407426
}
408427

409428
if haveError {
429+
settled := terminalFailure(instance)
410430
var reason condition.Reason
411431
reason = condition.ErrorReason
412432
severity := condition.SeverityWarning
413-
if backoffLimitReached {
433+
if settled {
414434
reason = condition.JobReasonBackoffLimitExceeded
415435
severity = condition.SeverityError
416436
}
@@ -420,7 +440,7 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
420440
severity,
421441
condition.DeploymentReadyErrorMessage,
422442
deploymentErrMsg)
423-
if backoffLimitReached {
443+
if settled {
424444
return ctrl.Result{}, nil
425445
}
426446
return ctrl.Result{}, fmt.Errorf("%s", deploymentErrMsg)
@@ -438,10 +458,6 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
438458
if version != nil {
439459
instance.Status.DeployedVersion = version.Spec.TargetVersion
440460
}
441-
err = r.setHashes(ctx, helper, instance, *nodeSets)
442-
if err != nil {
443-
Log.Error(err, "Error setting service hashes")
444-
}
445461
return ctrl.Result{}, nil
446462
}
447463

@@ -615,6 +631,33 @@ func (r *OpenStackDataPlaneDeploymentReconciler) listNodeSets(ctx context.Contex
615631
return &nodeSets, err
616632
}
617633

634+
// terminalFailure reports whether the deployment has a permanently failed
635+
// nodeSet and nothing left to wait for. A nodeSet still in flight keeps this
636+
// false even when another one already failed.
637+
func terminalFailure(instance *dataplanev1.OpenStackDataPlaneDeployment) bool {
638+
if len(instance.Spec.NodeSets) == 0 || len(instance.Status.FailedNodeSets) == 0 {
639+
return false
640+
}
641+
for _, nodeSet := range instance.Spec.NodeSets {
642+
if _, failed := instance.Status.FailedNodeSets[nodeSet]; failed {
643+
continue
644+
}
645+
nsConditions := instance.Status.NodeSetConditions[nodeSet]
646+
nsCondition := nsConditions.Get(dataplanev1.NodeSetDeploymentReadyCondition)
647+
if nsCondition == nil || nsCondition.Status != corev1.ConditionTrue {
648+
return false
649+
}
650+
}
651+
return true
652+
}
653+
654+
func appendDeploymentErrMsg(current string, errMsg string) string {
655+
if len(current) == 0 {
656+
return errMsg
657+
}
658+
return fmt.Sprintf("%s & %s", current, errMsg)
659+
}
660+
618661
func setNodeSetAnsibleVarsFromHashes(
619662
ctx context.Context,
620663
helper *helper.Helper,

0 commit comments

Comments
 (0)