allocrunner: Drop and log updates after closing waitCh

This commit is contained in:
Danielle Tomlinson 2018-12-18 23:36:29 +01:00
parent 0d91285cd6
commit d6eb084d8a
2 changed files with 17 additions and 0 deletions

View File

@ -629,7 +629,15 @@ func (ar *allocRunner) Update(update *structs.Allocation) {
"new_modify_index", update.AllocModifyIndex)
ar.allocUpdatedCh <- oldUpdate
return
} else {
ar.logger.Trace("Discarding allocation update",
"skipped_modify_index", oldUpdate.AllocModifyIndex,
"new_modify_index", update.AllocModifyIndex)
}
case <-ar.waitCh:
ar.logger.Trace("AllocRunner has terminated, skipping alloc update",
"modify_index", update.AllocModifyIndex)
return
default:
}

View File

@ -326,6 +326,15 @@ func TestAllocRunner_Update_Semantics(t *testing.T) {
queuedAlloc = <-ar.allocUpdatedCh
require.Equal(upd2, queuedAlloc)
// Ignore after watch closed
close(ar.waitCh)
ar.Update(upd1)
// Did not queue the update
require.Len(ar.allocUpdatedCh, 0)
}
/*