diff --git a/nomad/deploymentwatcher/deployment_watcher.go b/nomad/deploymentwatcher/deployment_watcher.go index 3286fb165daa..896b48e4463b 100644 --- a/nomad/deploymentwatcher/deployment_watcher.go +++ b/nomad/deploymentwatcher/deployment_watcher.go @@ -416,6 +416,7 @@ func (w *deploymentWatcher) watch() { } allocIndex := uint64(1) + allocsCh := w.getAllocsCh(allocIndex) var updates *allocUpdates rollback, deadlineHit := false, false @@ -487,7 +488,7 @@ FAIL: break FAIL } - case updates = <-w.getAllocsCh(allocIndex): + case updates = <-allocsCh: if err := updates.err; err != nil { if err == context.Canceled || w.ctx.Err() == context.Canceled { return @@ -531,6 +532,9 @@ FAIL: if res.createEval || len(res.allowReplacements) != 0 { w.createBatchedUpdate(res.allowReplacements, allocIndex) } + + // only start a new blocking query if we haven't returned early + allocsCh = w.getAllocsCh(allocIndex) } }