mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
Update ModifyIndex of alloc when setting NextAllocation value
This commit is contained in:
@@ -2037,6 +2037,7 @@ func (s *StateStore) upsertAllocsImpl(index uint64, allocs []*structs.Allocation
|
||||
if existingPrevAlloc != nil {
|
||||
prevAllocCopy := existingPrevAlloc.Copy()
|
||||
prevAllocCopy.NextAllocation = alloc.ID
|
||||
prevAllocCopy.ModifyIndex = index
|
||||
if err := txn.Insert("allocs", prevAllocCopy); err != nil {
|
||||
return fmt.Errorf("alloc insert failed: %v", err)
|
||||
}
|
||||
|
||||
@@ -4653,6 +4653,15 @@ func TestStateStore_Allocs_PrevAlloc(t *testing.T) {
|
||||
|
||||
require.Equal(allocs, out)
|
||||
require.False(watchFired(ws))
|
||||
|
||||
// Insert another alloc, verify index of previous alloc also got updated
|
||||
alloc := mock.Alloc()
|
||||
alloc.PreviousAllocation = allocs[0].ID
|
||||
err = state.UpsertAllocs(1001, []*structs.Allocation{alloc})
|
||||
require.Nil(err)
|
||||
alloc0, err := state.AllocByID(nil, allocs[0].ID)
|
||||
require.Nil(err)
|
||||
require.Equal(alloc0.ModifyIndex, uint64(1001))
|
||||
}
|
||||
|
||||
func TestStateStore_RestoreAlloc(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user