Add force node gc

This commit is contained in:
Alex Dadgar 2016-02-20 16:11:29 -08:00
parent a3ac4bbc5a
commit d42e0a7dfd
2 changed files with 14 additions and 8 deletions

View file

@ -240,12 +240,20 @@ func (c *CoreScheduler) nodeGC(eval *structs.Evaluation) error {
return err
}
// Compute the old threshold limit for GC using the FSM
// time table. This is a rough mapping of a time to the
// Raft index it belongs to.
tt := c.srv.fsm.TimeTable()
cutoff := time.Now().UTC().Add(-1 * c.srv.config.NodeGCThreshold)
oldThreshold := tt.NearestIndex(cutoff)
var oldThreshold uint64
if eval.TriggeredBy == structs.EvalTriggerForceGC {
// The GC was forced, so set the threshold to its maximum so everything
// will GC.
oldThreshold = math.MaxUint64
c.srv.logger.Println("[DEBUG] sched.core: forced node GC")
} else {
// Compute the old threshold limit for GC using the FSM
// time table. This is a rough mapping of a time to the
// Raft index it belongs to.
tt := c.srv.fsm.TimeTable()
cutoff := time.Now().UTC().Add(-1 * c.srv.config.NodeGCThreshold)
oldThreshold = tt.NearestIndex(cutoff)
}
c.srv.logger.Printf("[DEBUG] sched.core: node GC: scanning before index %d (%v)",
oldThreshold, c.srv.config.NodeGCThreshold)

View file

@ -190,7 +190,6 @@ func TestCoreScheduler_NodeGC_Force(t *testing.T) {
// Attempt the GC
gc := s1.forceCoreJobEval(structs.CoreJobNodeGC)
gc.ModifyIndex = 2000
err = core.Process(gc)
if err != nil {
t.Fatalf("err: %v", err)
@ -377,7 +376,6 @@ func TestCoreScheduler_JobGC_Force(t *testing.T) {
// Attempt the GC
gc := s1.forceCoreJobEval(structs.CoreJobJobGC)
gc.ModifyIndex = 2000
err = core.Process(gc)
if err != nil {
t.Fatalf("test(%s) err: %v", test.test, err)