From c07a932cea1c4457f58ee63711c48cbfdad6047e Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Mon, 25 Sep 2017 11:03:20 -0700 Subject: [PATCH] Run deployment garbage collector on an interval Fixes https://github.com/hashicorp/nomad/issues/3244 --- CHANGELOG.md | 1 + nomad/leader.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 356c88e8e09..c4f9d3f3501 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ IMPROVEMENTS: BUG FIXES: * core: Fix restoration of stopped periodic jobs [GH-3201] + * core: Run deployment garbage collector on an interval [GH-3267] * core: Fix issue where node-drain with complete batch allocation would create replacement [GH-3217] * core: Fix issue in which batch allocations from previous job versions may not diff --git a/nomad/leader.go b/nomad/leader.go index f09825d2378..10a386d1dd0 100644 --- a/nomad/leader.go +++ b/nomad/leader.go @@ -363,6 +363,8 @@ func (s *Server) schedulePeriodic(stopCh chan struct{}) { defer nodeGC.Stop() jobGC := time.NewTicker(s.config.JobGCInterval) defer jobGC.Stop() + deploymentGC := time.NewTicker(s.config.DeploymentGCInterval) + defer deploymentGC.Stop() // getLatest grabs the latest index from the state store. It returns true if // the index was retrieved successfully. @@ -391,6 +393,10 @@ func (s *Server) schedulePeriodic(stopCh chan struct{}) { if index, ok := getLatest(); ok { s.evalBroker.Enqueue(s.coreJobEval(structs.CoreJobJobGC, index)) } + case <-deploymentGC.C: + if index, ok := getLatest(); ok { + s.evalBroker.Enqueue(s.coreJobEval(structs.CoreJobDeploymentGC, index)) + } case <-stopCh: return }