diff --git a/nomad/core_sched.go b/nomad/core_sched.go index c5614b721dd..a3fbe4010da 100644 --- a/nomad/core_sched.go +++ b/nomad/core_sched.go @@ -319,7 +319,7 @@ func (c *CoreScheduler) gcEval(eval *structs.Evaluation, thresholdIndex uint64, // We don't want to gc anything related to a job which is not dead // If the batch job doesn't exist we can GC it regardless of allowBatch if !collect { - // Find allocs associated with older (based on modifyindex) and GC them if terminal + // Find allocs associated with older (based on createindex) and GC them if terminal oldAllocs := olderVersionTerminalAllocs(allocs, job) return false, oldAllocs, nil } @@ -342,12 +342,12 @@ func (c *CoreScheduler) gcEval(eval *structs.Evaluation, thresholdIndex uint64, return gcEval, gcAllocIDs, nil } -// olderVersionTerminalAllocs returns terminal allocations whose job modify index -// is older than the job's modify index +// olderVersionTerminalAllocs returns terminal allocations whose job create index +// is older than the job's create index func olderVersionTerminalAllocs(allocs []*structs.Allocation, job *structs.Job) []string { var ret []string for _, alloc := range allocs { - if alloc.Job != nil && alloc.Job.JobModifyIndex < job.JobModifyIndex && alloc.TerminalStatus() { + if alloc.Job != nil && alloc.Job.CreateIndex < job.CreateIndex && alloc.TerminalStatus() { ret = append(ret, alloc.ID) } } diff --git a/nomad/core_sched_test.go b/nomad/core_sched_test.go index 81c2784e597..02ea29ea367 100644 --- a/nomad/core_sched_test.go +++ b/nomad/core_sched_test.go @@ -440,7 +440,7 @@ func TestCoreScheduler_EvalGC_Batch_OldVersion(t *testing.T) { alloc3.Job = job2 alloc3.JobID = job2.ID alloc3.EvalID = eval.ID - job2.JobModifyIndex = 500 + job2.CreateIndex = 500 alloc3.DesiredStatus = structs.AllocDesiredStatusRun alloc3.ClientStatus = structs.AllocClientStatusLost