From 7f0d241ef422a6836de7fc3e9c3818197f91e2e7 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Fri, 21 Sep 2018 14:56:48 -0700 Subject: [PATCH] always handle failed allocation --- nomad/deploymentwatcher/deployment_watcher.go | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/nomad/deploymentwatcher/deployment_watcher.go b/nomad/deploymentwatcher/deployment_watcher.go index 7383c7977..6faf133e2 100644 --- a/nomad/deploymentwatcher/deployment_watcher.go +++ b/nomad/deploymentwatcher/deployment_watcher.go @@ -522,27 +522,20 @@ func (w *deploymentWatcher) handleAllocUpdate(allocs []*structs.AllocListStub) ( continue } - // We have a blocked evaluation for this job so we know that any change - // to cluster capacity will cause the scheduler to be invoked, thus - // observing any healthy allocation. We can not continue, because we - // still must handle the case of non-progress base deployments and - // allocations who have gone unhealthy. - if !blocked { - // Nothing to do for this allocation since we have already handled - // this allocation update in the latest eval - if alloc.DeploymentStatus == nil || alloc.DeploymentStatus.ModifyIndex <= latestEval { - continue - } - } - // Determine if the update stanza for this group is progress based progressBased := dstate.ProgressDeadline != 0 - // We need to create an eval so the job can progress. - if !blocked && alloc.DeploymentStatus.IsHealthy() { - res.createEval = true - } else if progressBased && alloc.DeploymentStatus.IsUnhealthy() && deployment.Active() && !alloc.DesiredTransition.ShouldReschedule() { + // Check if the allocation has failed and we need to mark it for allow + // replacements + if progressBased && alloc.DeploymentStatus.IsUnhealthy() && + deployment.Active() && !alloc.DesiredTransition.ShouldReschedule() { res.allowReplacements = append(res.allowReplacements, alloc.ID) + continue + } + + // We need to create an eval so the job can progress. + if !blocked && alloc.DeploymentStatus.IsHealthy() && alloc.DeploymentStatus.ModifyIndex > latestEval { + res.createEval = true } // If the group is using a progress deadline, we don't have to do anything.