From ce43ad613ebb069b5a1139884cc7e97587f49b53 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Tue, 5 Jul 2016 11:10:12 -0700 Subject: [PATCH] handled the logic of task group count going up --- nomad/state/state_store.go | 3 ++- nomad/structs/structs.go | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index 308860c1c..9813e251f 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -1205,7 +1205,6 @@ func (s *StateStore) updateSummaryWithJob(job *structs.Job, txn *memdb.Txn) erro for _, tg := range job.TaskGroups { if summary, ok := existing.Summary[tg.Name]; !ok { newSummary := structs.TaskGroupSummary{ - Name: tg.Name, Queued: tg.Count, Complete: 0, Failed: 0, @@ -1216,6 +1215,8 @@ func (s *StateStore) updateSummaryWithJob(job *structs.Job, txn *memdb.Txn) erro } else { if summary.Queued > tg.Count { summary.Queued = tg.Count + } else { + summary.Queued += tg.Count - (summary.Total()) } existing.Summary[tg.Name] = summary } diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index dfbc38739..bd2baea6b 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -957,6 +957,11 @@ type TaskGroupSummary struct { Starting int } +// Total returns the total number of allocations for the task group. +func (s *TaskGroupSummary) Total() int { + return s.Queued + s.Complete + s.Failed + s.Running + s.Starting +} + // Job is the scope of a scheduling request to Nomad. It is the largest // scoped object, and is a named collection of task groups. Each task group // is further composed of tasks. A task group (TG) is the unit of scheduling