@@ -137,7 +137,7 @@ OUTER:
137
137
allEvalsGC := true
138
138
var jobAlloc , jobEval []string
139
139
for _ , eval := range evals {
140
- gc , allocs , err := c .gcEval (eval , oldThreshold , oldThreshold , true )
140
+ gc , allocs , err := c .gcEval (eval , oldThreshold , true )
141
141
if err != nil {
142
142
continue OUTER
143
143
} else if gc {
@@ -246,9 +246,12 @@ func (c *CoreScheduler) evalGC(eval *structs.Evaluation) error {
246
246
for raw := iter .Next (); raw != nil ; raw = iter .Next () {
247
247
eval := raw .(* structs.Evaluation )
248
248
249
- // The Evaluation GC should not handle batch jobs since those need to be
250
- // garbage collected in one shot
251
- gc , allocs , err := c .gcEval (eval , oldThreshold , batchOldThreshold , false )
249
+ gcThreshold := oldThreshold
250
+ if eval .Type == structs .JobTypeBatch {
251
+ gcThreshold = batchOldThreshold
252
+ }
253
+
254
+ gc , allocs , err := c .gcEval (eval , gcThreshold , false )
252
255
if err != nil {
253
256
return err
254
257
}
@@ -274,15 +277,10 @@ func (c *CoreScheduler) evalGC(eval *structs.Evaluation) error {
274
277
// allocs are not older than the threshold. If the eval should be garbage
275
278
// collected, the associated alloc ids that should also be removed are also
276
279
// returned
277
- func (c * CoreScheduler ) gcEval (eval * structs.Evaluation , thresholdIndex uint64 , batchThresholdIndex uint64 , allowBatch bool ) (
280
+ func (c * CoreScheduler ) gcEval (eval * structs.Evaluation , thresholdIndex uint64 , allowBatch bool ) (
278
281
bool , []string , error ) {
279
282
// Ignore non-terminal and new evaluations
280
- if ! eval .TerminalStatus () {
281
- return false , nil , nil
282
- }
283
-
284
- if (eval .Type == structs .JobTypeBatch && eval .ModifyIndex > batchThresholdIndex ) ||
285
- (eval .Type != structs .JobTypeBatch && eval .ModifyIndex > thresholdIndex ) {
283
+ if ! eval .TerminalStatus () || eval .ModifyIndex > thresholdIndex {
286
284
return false , nil , nil
287
285
}
288
286
@@ -319,19 +317,9 @@ func (c *CoreScheduler) gcEval(eval *structs.Evaluation, thresholdIndex uint64,
319
317
// - allowBatch and the job is dead
320
318
//
321
319
// If we cannot collect outright, check if a partial GC may occur
322
- collect := false
323
- if job == nil {
324
- collect = true
325
- } else if job .Status != structs .JobStatusDead {
326
- collect = false
327
- } else if job .Stop {
328
- collect = true
329
- } else if allowBatch {
330
- collect = true
331
- }
332
-
320
+ collect := job == nil || job .Status == structs .JobStatusDead && (job .Stop || allowBatch )
333
321
if ! collect {
334
- oldAllocs := olderVersionTerminalAllocs (allocs , job , batchThresholdIndex )
322
+ oldAllocs := olderVersionTerminalAllocs (allocs , job , thresholdIndex )
335
323
gcEval := (len (oldAllocs ) == len (allocs ))
336
324
return gcEval , oldAllocs , nil
337
325
}
0 commit comments