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,
|
Queued: 10,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CreateIndex: latestIndex,
|
CreateIndex: 1000,
|
||||||
ModifyIndex: latestIndex,
|
ModifyIndex: latestIndex,
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(&expected, out1) {
|
if !reflect.DeepEqual(&expected, out1) {
|
||||||
|
@ -1036,7 +1036,7 @@ func TestFSM_SnapshotRestore_AddMissingSummary(t *testing.T) {
|
||||||
Starting: 1,
|
Starting: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CreateIndex: latestIndex,
|
CreateIndex: 1010,
|
||||||
ModifyIndex: latestIndex,
|
ModifyIndex: latestIndex,
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(&expected, out2) {
|
if !reflect.DeepEqual(&expected, out2) {
|
||||||
|
|
|
@ -1219,6 +1219,13 @@ func (s *StateStore) ReconcileJobSummaries(index uint64) error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
alloc := rawAlloc.(*structs.Allocation)
|
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]
|
tg := summary.Summary[alloc.TaskGroup]
|
||||||
switch alloc.ClientStatus {
|
switch alloc.ClientStatus {
|
||||||
case structs.AllocClientStatusFailed:
|
case structs.AllocClientStatusFailed:
|
||||||
|
@ -1237,9 +1244,12 @@ func (s *StateStore) ReconcileJobSummaries(index uint64) error {
|
||||||
summary.Summary[alloc.TaskGroup] = tg
|
summary.Summary[alloc.TaskGroup] = tg
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert the job summary
|
// Set the create index of the summary same as the job's create index
|
||||||
summary.CreateIndex = index
|
// and the modify index to the current index
|
||||||
|
summary.CreateIndex = job.CreateIndex
|
||||||
summary.ModifyIndex = index
|
summary.ModifyIndex = index
|
||||||
|
|
||||||
|
// Insert the job summary
|
||||||
if err := txn.Insert("job_summary", summary); err != nil {
|
if err := txn.Insert("job_summary", summary); err != nil {
|
||||||
return fmt.Errorf("error inserting job summary: %v", err)
|
return fmt.Errorf("error inserting job summary: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2059,7 +2059,7 @@ func TestStateStore_ReconcileJobSummary(t *testing.T) {
|
||||||
Lost: 1,
|
Lost: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CreateIndex: 120,
|
CreateIndex: 100,
|
||||||
ModifyIndex: 120,
|
ModifyIndex: 120,
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(&expectedSummary, summary) {
|
if !reflect.DeepEqual(&expectedSummary, summary) {
|
||||||
|
|
Loading…
Reference in a new issue