mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user