Change default behavior in Nomad Event Handling
to not propagate that pending runners are being stopped.
This commit is contained in:

committed by
Sebastian Serth

parent
2eb15c8d93
commit
90d591d4ec
@ -453,7 +453,8 @@ func handlePendingAllocationEvent(alloc *nomadApi.Allocation, allocData *allocat
|
|||||||
stopExpected: stopExpected,
|
stopExpected: stopExpected,
|
||||||
})
|
})
|
||||||
case structs.AllocDesiredStatusStop:
|
case structs.AllocDesiredStatusStop:
|
||||||
handleStoppingAllocationEvent(alloc, allocations, callbacks, false)
|
// As this allocation was still pending, we don't have to propagate its deletion.
|
||||||
|
allocations.Delete(alloc.ID)
|
||||||
// Anyway, we want to monitor the occurrences.
|
// Anyway, we want to monitor the occurrences.
|
||||||
if !allocData.stopExpected {
|
if !allocData.stopExpected {
|
||||||
log.WithField("alloc", alloc).Warn("Pending allocation was stopped unexpectedly")
|
log.WithField("alloc", alloc).Warn("Pending allocation was stopped unexpectedly")
|
||||||
|
@ -518,9 +518,9 @@ func (s *MainTestSuite) TestApiClient_WatchAllocationsUsesCallbacksForEvents() {
|
|||||||
stoppedPendingAllocation := createRecentAllocation(structs.AllocClientStatusPending, structs.AllocDesiredStatusStop)
|
stoppedPendingAllocation := createRecentAllocation(structs.AllocClientStatusPending, structs.AllocDesiredStatusStop)
|
||||||
stoppedPendingEvents := nomadApi.Events{Events: []nomadApi.Event{eventForAllocation(s.T(), stoppedPendingAllocation)}}
|
stoppedPendingEvents := nomadApi.Events{Events: []nomadApi.Event{eventForAllocation(s.T(), stoppedPendingAllocation)}}
|
||||||
|
|
||||||
s.Run("it removes stopped pending allocations", func() {
|
s.Run("it does not callback for stopped pending allocations", func() {
|
||||||
assertWatchAllocation(s, []*nomadApi.Events{&pendingEvents, &stoppedPendingEvents},
|
assertWatchAllocation(s, []*nomadApi.Events{&pendingEvents, &stoppedPendingEvents},
|
||||||
[]*nomadApi.Allocation(nil), []string{stoppedPendingAllocation.JobID})
|
[]*nomadApi.Allocation(nil), []string(nil))
|
||||||
})
|
})
|
||||||
|
|
||||||
failedAllocation := createRecentAllocation(structs.AllocClientStatusFailed, structs.AllocDesiredStatusStop)
|
failedAllocation := createRecentAllocation(structs.AllocClientStatusFailed, structs.AllocDesiredStatusStop)
|
||||||
|
Reference in New Issue
Block a user