Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ spec:
deployedVersion:
description: DeployedVersion
type: string
failedNodeSets:
additionalProperties:
type: string
description: |-
FailedNodeSets maps a nodeSet name to the message of the permanent failure
that terminated it. Terminality cannot live in the conditions because the AEE
job backing the failure is garbage collected once the deployment settles.
type: object
nodeSetConditions:
additionalProperties:
description: Conditions provide observations of the operational
Expand Down
5 changes: 5 additions & 0 deletions api/dataplane/v1beta1/openstackdataplanedeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ type OpenStackDataPlaneDeploymentStatus struct {
// NodeSetConditions
NodeSetConditions map[string]condition.Conditions `json:"nodeSetConditions,omitempty" optional:"true"`

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

// AnsibleEEHashes
AnsibleEEHashes map[string]string `json:"ansibleEEHashes,omitempty" optional:"true"`

Expand Down
7 changes: 7 additions & 0 deletions api/dataplane/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions bindata/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20863,6 +20863,14 @@ spec:
deployedVersion:
description: DeployedVersion
type: string
failedNodeSets:
additionalProperties:
type: string
description: |-
FailedNodeSets maps a nodeSet name to the message of the permanent failure
that terminated it. Terminality cannot live in the conditions because the AEE
job backing the failure is garbage collected once the deployment settles.
type: object
nodeSetConditions:
additionalProperties:
description: Conditions provide observations of the operational
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ spec:
deployedVersion:
description: DeployedVersion
type: string
failedNodeSets:
additionalProperties:
type: string
description: |-
FailedNodeSets maps a nodeSet name to the message of the permanent failure
that terminated it. Terminality cannot live in the conditions because the AEE
job backing the failure is garbage collected once the deployment settles.
type: object
nodeSetConditions:
additionalProperties:
description: Conditions provide observations of the operational
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,10 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
return ctrl.Result{}, nil
}

// If the deployment has failed with backoff limit exceeded, do not reconcile
// even if nodesets or other watched resources change. The deployment is in a
// terminal failure state and should not be retried.
if instance.Status.Conditions != nil {
deploymentCondition := instance.Status.Conditions.Get(condition.DeploymentReadyCondition)
if deploymentCondition != nil &&
deploymentCondition.Severity == condition.SeverityError &&
deploymentCondition.Reason == condition.JobReasonBackoffLimitExceeded {
Log.Info("Deployment has failed with backoff limit exceeded, skipping reconciliation",
Comment thread
rabi marked this conversation as resolved.
Resolved
"deployment", instance.Name)
return ctrl.Result{}, nil
}
if terminalFailure(instance) {
Log.Info("Deployment is terminal, skipping reconciliation",
"deployment", instance.Name)
return ctrl.Result{}, nil
}

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

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

if failure, ok := instance.Status.FailedNodeSets[nodeSet.Name]; ok {
Log.Info("NodeSet already terminated by a permanent failure", "nodeSet", nodeSet.Name)
nsConditions := instance.Status.NodeSetConditions[nodeSet.Name]
nsConditions.MarkFalse(
dataplanev1.NodeSetDeploymentReadyCondition,
condition.JobReasonBackoffLimitExceeded,
condition.SeverityError,
"%s", failure)
instance.Status.NodeSetConditions[nodeSet.Name] = nsConditions
haveError = true
deploymentErrMsg = appendDeploymentErrMsg(deploymentErrMsg,
fmt.Sprintf("nodeSet: %s error: %s", nodeSet.Name, failure))
continue
}

Log.Info("Deploying NodeSet", "nodeSet", nodeSet.Name)
Log.Info("Set Status.Deployed to false", "instance", instance)
instance.Status.Deployed = false
Expand Down Expand Up @@ -413,14 +423,12 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
util.LogErrorForObject(helper, err, fmt.Sprintf("OpenStackDeployment error for NodeSet %s", nodeSet.Name), instance)
Log.Info("Set NodeSetDeploymentReadyCondition false", "nodeSet", nodeSet.Name)
haveError = true
errMsg := fmt.Sprintf("nodeSet: %s error: %s", nodeSet.Name, err.Error())
if len(deploymentErrMsg) == 0 {
deploymentErrMsg = errMsg
} else {
deploymentErrMsg = fmt.Sprintf("%s & %s", deploymentErrMsg, errMsg)
deploymentErrMsg = appendDeploymentErrMsg(deploymentErrMsg,
fmt.Sprintf("nodeSet: %s error: %s", nodeSet.Name, err.Error()))
if nsConditions.Get(dataplanev1.NodeSetDeploymentReadyCondition) != nil &&
nsConditions.Get(dataplanev1.NodeSetDeploymentReadyCondition).Reason == condition.JobReasonBackoffLimitExceeded {
instance.Status.FailedNodeSets[nodeSet.Name] = err.Error()
}
errorReason := nsConditions.Get(dataplanev1.NodeSetDeploymentReadyCondition).Reason
backoffLimitReached = errorReason == condition.JobReasonBackoffLimitExceeded
}

if deployResult != nil {
Expand All @@ -431,16 +439,26 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
nsConditions.MarkTrue(
dataplanev1.NodeSetDeploymentReadyCondition,
condition.DeploymentReadyMessage)
instance.Status.NodeSetHashes[nodeSet.Name] = nodeSet.Status.ConfigHash
instance.Status.BmhRefHashes[nodeSet.Name] = nodeSet.Status.BmhRefHash
finishedNodeSets = append(finishedNodeSets, *nodeSet)
}
}

// A nodeSet that finished alongside a failure must still get its hashes, or the
// NodeSet controller re-deploys it because its inputs look changed.
if len(finishedNodeSets) > 0 {
err = r.setHashes(ctx, helper, instance,
dataplanev1.OpenStackDataPlaneNodeSetList{Items: finishedNodeSets})
if err != nil {
return ctrl.Result{}, err
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

if haveError {
settled := terminalFailure(instance)
var reason condition.Reason
reason = condition.ErrorReason
severity := condition.SeverityWarning
if backoffLimitReached {
if settled {
reason = condition.JobReasonBackoffLimitExceeded
severity = condition.SeverityError
}
Expand All @@ -450,7 +468,7 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
severity,
condition.DeploymentReadyErrorMessage,
deploymentErrMsg)
if backoffLimitReached {
if settled {
return ctrl.Result{}, nil
}
return ctrl.Result{}, fmt.Errorf("%s", deploymentErrMsg)
Expand All @@ -468,10 +486,6 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
if version != nil {
instance.Status.DeployedVersion = version.Spec.TargetVersion
}
err = r.setHashes(ctx, helper, instance, *nodeSets)
if err != nil {
Log.Error(err, "Error setting service hashes")
}
return ctrl.Result{}, nil
}

Expand Down Expand Up @@ -600,14 +614,19 @@ func (r *OpenStackDataPlaneDeploymentReconciler) setHashes(
}

for _, nodeSet := range nodeSets.Items {
instance.Status.NodeSetHashes[nodeSet.Name] = nodeSet.Status.ConfigHash

err = setNodeSetAnsibleVarsFromHashes(ctx, helper, &nodeSet, instance.Status.ConfigMapHashes, instance.Status.SecretHashes)
if err != nil {
return err
}
}

// Split from the loop above: terminalFailure reads a NodeSetHashes entry as proof
// the nodeSet's input hashes are recorded, so nothing above may fail after it.
for _, nodeSet := range nodeSets.Items {
instance.Status.NodeSetHashes[nodeSet.Name] = nodeSet.Status.ConfigHash
instance.Status.BmhRefHashes[nodeSet.Name] = nodeSet.Status.BmhRefHash
}

return nil
}

Expand Down Expand Up @@ -703,6 +722,39 @@ func (r *OpenStackDataPlaneDeploymentReconciler) listNodeSets(ctx context.Contex
return &nodeSets, err
}

// terminalFailure reports whether the deployment has a permanently failed
// nodeSet and nothing left to wait for. A nodeSet still in flight keeps this
// false even when another one already failed. Deployments that failed before
// FailedNodeSets existed carry the failure only on the top-level condition, so
// honor it as well: their backing jobs are garbage collected and must not be
// recreated.
func terminalFailure(instance *dataplanev1.OpenStackDataPlaneDeployment) bool {
Comment thread
rabi marked this conversation as resolved.
Resolved
if c := instance.Status.Conditions.Get(condition.DeploymentReadyCondition); c != nil &&
c.Severity == condition.SeverityError &&
c.Reason == condition.JobReasonBackoffLimitExceeded {
return true
}
if len(instance.Spec.NodeSets) == 0 || len(instance.Status.FailedNodeSets) == 0 {
return false
}
for _, nodeSet := range instance.Spec.NodeSets {
if _, failed := instance.Status.FailedNodeSets[nodeSet]; failed {
continue
}
if _, done := instance.Status.NodeSetHashes[nodeSet]; !done {
return false
}
}
return true
}

func appendDeploymentErrMsg(current string, errMsg string) string {
if len(current) == 0 {
return errMsg
}
return fmt.Sprintf("%s & %s", current, errMsg)
}

func setNodeSetAnsibleVarsFromHashes(
ctx context.Context,
helper *helper.Helper,
Expand Down
Loading
Loading