Merge pull request #1522 from hashicorp/b-reconcile-summary
Setting job's create index as summary create index during reconciliation
This commit is contained in:
commit
1813a5fa1f
|
@ -1017,7 +1017,7 @@ func TestFSM_SnapshotRestore_AddMissingSummary(t *testing.T) {
|
|||
Queued: 10,
|
||||
},
|
||||
},
|
||||
CreateIndex: latestIndex,
|
||||
CreateIndex: 1000,
|
||||
ModifyIndex: latestIndex,
|
||||
}
|
||||
if !reflect.DeepEqual(&expected, out1) {
|
||||
|
@ -1036,7 +1036,7 @@ func TestFSM_SnapshotRestore_AddMissingSummary(t *testing.T) {
|
|||
Starting: 1,
|
||||
},
|
||||
},
|
||||
CreateIndex: latestIndex,
|
||||
CreateIndex: 1010,
|
||||
ModifyIndex: latestIndex,
|
||||
}
|
||||
if !reflect.DeepEqual(&expected, out2) {
|
||||
|
|
|
@ -1219,6 +1219,13 @@ func (s *StateStore) ReconcileJobSummaries(index uint64) error {
|
|||
break
|
||||
}
|
||||
alloc := rawAlloc.(*structs.Allocation)
|
||||
|
||||
// Ignore the allocation if it doesn't belong to the currently
|
||||
// registered job
|
||||
if alloc.Job.CreateIndex != job.CreateIndex {
|
||||
continue
|
||||
}
|
||||
|
||||
tg := summary.Summary[alloc.TaskGroup]
|
||||
switch alloc.ClientStatus {
|
||||
case structs.AllocClientStatusFailed:
|
||||
|
@ -1237,9 +1244,12 @@ func (s *StateStore) ReconcileJobSummaries(index uint64) error {
|
|||
summary.Summary[alloc.TaskGroup] = tg
|
||||
}
|
||||
|
||||
// Insert the job summary
|
||||
summary.CreateIndex = index
|
||||
// Set the create index of the summary same as the job's create index
|
||||
// and the modify index to the current index
|
||||
summary.CreateIndex = job.CreateIndex
|
||||
summary.ModifyIndex = index
|
||||
|
||||
// Insert the job summary
|
||||
if err := txn.Insert("job_summary", summary); err != nil {
|
||||
return fmt.Errorf("error inserting job summary: %v", err)
|
||||
}
|
||||
|
|
|
@ -2059,7 +2059,7 @@ func TestStateStore_ReconcileJobSummary(t *testing.T) {
|
|||
Lost: 1,
|
||||
},
|
||||
},
|
||||
CreateIndex: 120,
|
||||
CreateIndex: 100,
|
||||
ModifyIndex: 120,
|
||||
}
|
||||
if !reflect.DeepEqual(&expectedSummary, summary) {
|
||||
|
|
Loading…
Reference in a new issue