Updating the job summary table only if an evaluation has any Queued Allocations

This commit is contained in:
Diptanu Choudhury
2016-07-19 11:18:05 -07:00
parent 38b1ba7e4e
commit 6e9b955f84

View File

@@ -658,13 +658,27 @@ func (s *StateStore) nestedUpsertEval(txn *memdb.Txn, index uint64, eval *struct
}
if summaryRaw != nil {
js := summaryRaw.(*structs.JobSummary)
var hasSummaryChanged bool
for tg, num := range eval.QueuedAllocations {
if summary, ok := js.Summary[tg]; ok {
summary.Queued = num
js.Summary[tg] = summary
hasSummaryChanged = true
} else {
s.logger.Printf("[ERR] state_store: unable to update queued for job %q and task group %q", eval.JobID, tg)
}
}
// Insert the job summary
if hasSummaryChanged {
js.ModifyIndex = index
if err := txn.Insert("job_summary", js); err != nil {
return fmt.Errorf("job summary insert failed: %v", err)
}
if err := txn.Insert("index", &IndexEntry{"job_summary", index}); err != nil {
return fmt.Errorf("index update failed: %v", err)
}
}
}
// Insert the eval