Setting job's create index as summary create index during reconciliation

This commit is contained in:
Diptanu Choudhury
2016-08-04 15:14:01 -07:00
parent ece625166f
commit cdb4d5e00f
3 changed files with 15 additions and 5 deletions

View File

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

View File

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

View File

@@ -2059,7 +2059,7 @@ func TestStateStore_ReconcileJobSummary(t *testing.T) {
Lost: 1,
},
},
CreateIndex: 120,
CreateIndex: 100,
ModifyIndex: 120,
}
if !reflect.DeepEqual(&expectedSummary, summary) {