@@ -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+
618661func setNodeSetAnsibleVarsFromHashes (
619662 ctx context.Context ,
620663 helper * helper.Helper ,
0 commit comments