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
This commit is contained in:
Alex Dadgar 2017-04-14 13:09:54 -07:00
parent ba052d8405
commit 61f4a2dac6

View file

@ -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: