From 6e9b955f8488f1e2bd0120ade1beda09f6e9237a Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Tue, 19 Jul 2016 11:18:05 -0700 Subject: [PATCH] Updating the job summary table only if an evaluation has any Queued Allocations --- nomad/state/state_store.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index b2d707426..5f194e41b 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -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