mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 10:55:42 +03:00
handled the logic of task group count going up
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user