allocrunner: Drop and log updates after closing waitCh
This commit is contained in:
parent
0d91285cd6
commit
d6eb084d8a
|
@ -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:
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue