mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
Track previous node id correctly, plus unit test
This commit is contained in:
@@ -531,7 +531,7 @@ func updateRescheduleTracker(alloc *structs.Allocation, prev *structs.Allocation
|
||||
rescheduleEvents = append(rescheduleEvents, reschedEvent.Copy())
|
||||
}
|
||||
}
|
||||
rescheduleEvent := structs.NewRescheduleEvent(time.Now().UTC().UnixNano(), prev.ID, alloc.NodeID)
|
||||
rescheduleEvent := structs.NewRescheduleEvent(time.Now().UTC().UnixNano(), prev.ID, prev.NodeID)
|
||||
rescheduleEvents = append(rescheduleEvents, rescheduleEvent)
|
||||
alloc.RescheduleTracker = &structs.RescheduleTracker{Events: rescheduleEvents}
|
||||
}
|
||||
|
||||
@@ -2867,6 +2867,9 @@ func TestServiceSched_Reschedule_Multiple(t *testing.T) {
|
||||
expectedNumAllocs := 3
|
||||
expectedNumReschedTrackers := 1
|
||||
|
||||
failedAllocId := allocs[1].ID
|
||||
failedNodeID := allocs[1].NodeID
|
||||
|
||||
assert := assert.New(t)
|
||||
for i := 0; i < maxRestartAttempts; i++ {
|
||||
// Process the evaluation
|
||||
@@ -2897,9 +2900,17 @@ func TestServiceSched_Reschedule_Multiple(t *testing.T) {
|
||||
newAlloc := pendingAllocs[0]
|
||||
assert.Equal(expectedNumReschedTrackers, len(newAlloc.RescheduleTracker.Events))
|
||||
|
||||
// Verify the previous NodeID in the most recent reschedule event
|
||||
reschedEvents := newAlloc.RescheduleTracker.Events
|
||||
assert.Equal(failedAllocId, reschedEvents[len(reschedEvents)-1].PrevAllocID)
|
||||
assert.Equal(failedNodeID, reschedEvents[len(reschedEvents)-1].PrevNodeID)
|
||||
|
||||
// Mark this alloc as failed again
|
||||
newAlloc.ClientStatus = structs.AllocClientStatusFailed
|
||||
|
||||
failedAllocId = newAlloc.ID
|
||||
failedNodeID = newAlloc.NodeID
|
||||
|
||||
noErr(t, h.State.UpsertAllocs(h.NextIndex(), []*structs.Allocation{newAlloc}))
|
||||
|
||||
// Create another mock evaluation
|
||||
|
||||
Reference in New Issue
Block a user