diff --git a/internal/nomad/nomad.go b/internal/nomad/nomad.go index 3e323c2..2f9b0ef 100644 --- a/internal/nomad/nomad.go +++ b/internal/nomad/nomad.go @@ -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") diff --git a/internal/nomad/nomad_test.go b/internal/nomad/nomad_test.go index 25a290b..9321a87 100644 --- a/internal/nomad/nomad_test.go +++ b/internal/nomad/nomad_test.go @@ -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)