reconcile should not overwrite unblocking state (#8349)

Pre-0.12.0 beta, a deployment was considered "complete" if it was
successful. But with MRD we have "blocked" and "unblocking" states as well. We
did not consider the case where a concurrent alloc health status update
triggers a `Compute` call on a deployment that's moved from "blocked" to
"unblocking" (it's a small window), which caused an extra pass thru the
`nextRegion` logic in `deploymentwatcher` and triggered an error when later
transitioning to "successful".

This changeset makes sure we don't overwrite that status.
This commit is contained in:
Tim Gross
2020-07-06 11:31:33 -04:00
committed by GitHub
parent e2831c5ecd
commit 114881c2aa

View File

@@ -218,23 +218,24 @@ func (a *allocReconciler) Compute() *reconcileResults {
// Mark the deployment as complete if possible
if a.deployment != nil && complete {
var status string
var desc string
if a.job.IsMultiregion() {
status = structs.DeploymentStatusBlocked
desc = structs.DeploymentStatusDescriptionBlocked
// the unblocking/successful states come after blocked, so we
// need to make sure we don't revert those states
if a.deployment.Status != structs.DeploymentStatusUnblocking &&
a.deployment.Status != structs.DeploymentStatusSuccessful {
a.result.deploymentUpdates = append(a.result.deploymentUpdates, &structs.DeploymentStatusUpdate{
DeploymentID: a.deployment.ID,
Status: structs.DeploymentStatusBlocked,
StatusDescription: structs.DeploymentStatusDescriptionBlocked,
})
}
} else {
status = structs.DeploymentStatusSuccessful
desc = structs.DeploymentStatusDescriptionSuccessful
a.result.deploymentUpdates = append(a.result.deploymentUpdates, &structs.DeploymentStatusUpdate{
DeploymentID: a.deployment.ID,
Status: structs.DeploymentStatusSuccessful,
StatusDescription: structs.DeploymentStatusDescriptionSuccessful,
})
}
a.result.deploymentUpdates = append(a.result.deploymentUpdates, &structs.DeploymentStatusUpdate{
DeploymentID: a.deployment.ID,
Status: status,
StatusDescription: desc,
})
}
// Set the description of a created deployment