From 9e2205f1d31c48c0817f84214de49587a9cda1a4 Mon Sep 17 00:00:00 2001 From: Preetha Appan Date: Mon, 3 Dec 2018 11:16:35 -0600 Subject: [PATCH] Add guards around subtracting summary count --- nomad/state/state_store.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index e7edc1db07c2..91e11f65c36e 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -3545,11 +3545,17 @@ func (s *StateStore) updateSummaryWithAlloc(index uint64, alloc *structs.Allocat // Decrementing the count of the bin of the last state switch existingAlloc.ClientStatus { case structs.AllocClientStatusRunning: - tgSummary.Running -= 1 + if tgSummary.Running > 0 { + tgSummary.Running -= 1 + } case structs.AllocClientStatusPending: - tgSummary.Starting -= 1 + if tgSummary.Starting > 0 { + tgSummary.Starting -= 1 + } case structs.AllocClientStatusLost: - tgSummary.Lost -= 1 + if tgSummary.Lost > 0 { + tgSummary.Lost -= 1 + } case structs.AllocClientStatusFailed, structs.AllocClientStatusComplete: default: s.logger.Printf("[ERR] state_store: invalid old state of allocation with id: %v, and state: %v",