mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
state store: persist NextAllocation correctly when upserting allocations (#25799)
--------- Co-authored-by: Tim Gross <tgross@hashicorp.com>
This commit is contained in:
committed by
GitHub
parent
456d95a19e
commit
979d34a461
3
.changelog/25799.txt
Normal file
3
.changelog/25799.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
reconnecting client: fix issue where reconcile strategy was sometimes ignored
|
||||
```
|
||||
@@ -4185,6 +4185,11 @@ func (s *StateStore) upsertAllocsImpl(index uint64, allocs []*structs.Allocation
|
||||
alloc.ModifyIndex = index
|
||||
alloc.AllocModifyIndex = index
|
||||
|
||||
// Carry over NextAllocation from existing
|
||||
if exist.NextAllocation != "" {
|
||||
alloc.NextAllocation = exist.NextAllocation
|
||||
}
|
||||
|
||||
// Keep the clients task states
|
||||
alloc.TaskStates = exist.TaskStates
|
||||
|
||||
|
||||
@@ -6587,6 +6587,31 @@ func TestStateStore_UpsertAlloc_ChildJob(t *testing.T) {
|
||||
require.False(t, watchFired(ws))
|
||||
}
|
||||
|
||||
func TestStateStore_UpsertAlloc_NextAllocation(t *testing.T) {
|
||||
ci.Parallel(t)
|
||||
|
||||
state := testStateStore(t)
|
||||
|
||||
alloc1 := mock.Alloc()
|
||||
alloc2 := mock.Alloc()
|
||||
alloc2.PreviousAllocation = alloc1.ID
|
||||
|
||||
err := state.UpsertAllocs(structs.MsgTypeTestSetup, 1000, []*structs.Allocation{alloc1, alloc2})
|
||||
must.NoError(t, err)
|
||||
|
||||
// alloc1 should have the correct NextAllocation
|
||||
actual, err := state.AllocByID(nil, alloc1.ID)
|
||||
must.Eq(t, actual.NextAllocation, alloc2.ID)
|
||||
|
||||
err = state.UpsertAllocs(structs.MsgTypeTestSetup, 1001, []*structs.Allocation{alloc2, alloc1})
|
||||
must.NoError(t, err)
|
||||
|
||||
// upsert in a different order, alloc1 should still have the correct NextAllocation
|
||||
actual, err = state.AllocByID(nil, alloc1.ID)
|
||||
must.NoError(t, err)
|
||||
must.Eq(t, actual.NextAllocation, alloc2.ID)
|
||||
}
|
||||
|
||||
func TestStateStore_UpdateAlloc_Alloc(t *testing.T) {
|
||||
ci.Parallel(t)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user