Deregister garbage collected jobs

This commit is contained in:
Michael Schurter
2018-03-19 10:18:20 -07:00
parent 74dc8fd460
commit 8ef7863bed

View File

@@ -189,12 +189,19 @@ func (w *drainingJobWatcher) watch() {
w.logger.Printf("[TRACE] nomad.drain.job_watcher: handling job %v", jns)
// Lookup the job
job, err := w.state.JobByID(nil, jns.Namespace, jns.ID)
if err != nil || job == nil {
job, err := snap.JobByID(nil, jns.Namespace, jns.ID)
if err != nil {
w.logger.Printf("[WARN] nomad.drain.job_watcher: failed to lookup job %v: %v", jns, err)
continue
}
// Ignore purged jobs
if job == nil {
w.logger.Printf("[TRACE] nomad.drain.job_watcher: ignoring garbage collected job %q", jns)
w.deregisterJob(jns.ID, jns.Namespace)
continue
}
// Ignore all non-service jobs
if job.Type != structs.JobTypeService {
w.deregisterJob(job.ID, job.Namespace)