handled the logic of task group count going up

This commit is contained in:
Diptanu Choudhury
2016-07-05 11:10:12 -07:00
parent 7b51b58edc
commit ce43ad613e
2 changed files with 7 additions and 1 deletions

View File

@@ -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
}

View File

@@ -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