From 3018ae07bbef57174bad82e6c5192594f082b035 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Fri, 14 Apr 2017 13:09:54 -0700 Subject: [PATCH] Sync allocation state before waiting for a destroy This change ensures that the client syncs allocation state with the servers before entering its wait loop for the allocation to be destroyed. Fixes https://github.com/hashicorp/nomad/issues/2563 --- client/alloc_runner.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/alloc_runner.go b/client/alloc_runner.go index 9215967a751..719a84d4a67 100644 --- a/client/alloc_runner.go +++ b/client/alloc_runner.go @@ -578,14 +578,15 @@ func (r *AllocRunner) destroyTaskRunners(destroyEvent *structs.TaskEvent) { for _, tr := range runners { <-tr.WaitCh() } - - // Final state sync - r.syncStatus() } // handleDestroy blocks till the AllocRunner should be destroyed and does the // necessary cleanup. func (r *AllocRunner) handleDestroy() { + // Final state sync. We do this to ensure that the server has the correct + // state as we wait for a destroy. + r.syncStatus() + for { select { case <-r.destroyCh: