Change default behavior in Nomad Event Handling

to not propagate that pending runners are being stopped.
This commit is contained in:
Maximilian Paß
2023-09-17 18:57:52 +02:00
committed by Sebastian Serth
parent 2eb15c8d93
commit 90d591d4ec
2 changed files with 4 additions and 3 deletions

View File

@ -453,7 +453,8 @@ func handlePendingAllocationEvent(alloc *nomadApi.Allocation, allocData *allocat
stopExpected: stopExpected,
})
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.
if !allocData.stopExpected {
log.WithField("alloc", alloc).Warn("Pending allocation was stopped unexpectedly")

View File

@ -518,9 +518,9 @@ func (s *MainTestSuite) TestApiClient_WatchAllocationsUsesCallbacksForEvents() {
stoppedPendingAllocation := createRecentAllocation(structs.AllocClientStatusPending, structs.AllocDesiredStatusStop)
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},
[]*nomadApi.Allocation(nil), []string{stoppedPendingAllocation.JobID})
[]*nomadApi.Allocation(nil), []string(nil))
})
failedAllocation := createRecentAllocation(structs.AllocClientStatusFailed, structs.AllocDesiredStatusStop)