From 35e22722051826cb4a750b22b8a27fd469066e42 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Fri, 27 Oct 2017 09:34:50 -0700 Subject: [PATCH 1/2] Bypass status checks for system, periodic, parameterized jobs --- nomad/state/state_store.go | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index 9214679d80b..62bb4948022 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -2839,6 +2839,16 @@ func (s *StateStore) getJobStatus(txn *memdb.Txn, job *structs.Job, evalDelete b job.Namespace = structs.DefaultNamespace } + // System, Periodic and Parameterized jobs are running until explicitly + // stopped + if job.Type == structs.JobTypeSystem || job.IsParameterized() || job.IsPeriodic() { + if job.Stop { + return structs.JobStatusDead, nil + } + + return structs.JobStatusRunning, nil + } + allocs, err := txn.Get("allocs", "job", job.Namespace, job.ID) if err != nil { return "", err @@ -2873,33 +2883,12 @@ func (s *StateStore) getJobStatus(txn *memdb.Txn, job *structs.Job, evalDelete b } } - // system jobs are running until explicitly stopped (which is handled elsewhere) - if job.Type == structs.JobTypeSystem { - if job.Stop { - return structs.JobStatusDead, nil - } - - // Pending until at least one eval has completed - return structs.JobStatusRunning, nil - } - // The job is dead if all the allocations and evals are terminal or if there // are no evals because of garbage collection. if evalDelete || hasEval || hasAlloc { return structs.JobStatusDead, nil } - // If there are no allocations or evaluations it is a new job. If the - // job is periodic or is a parameterized job, we mark it as running as - // it will never have an allocation/evaluation against it. - if job.IsPeriodic() || job.IsParameterized() { - // If the job is stopped mark it as dead - if job.Stop { - return structs.JobStatusDead, nil - } - - return structs.JobStatusRunning, nil - } return structs.JobStatusPending, nil } From e45f83d36de553717d76355676d95459d1b6976d Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Fri, 27 Oct 2017 09:36:16 -0700 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0267b8ac15..d1913616e35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ IMPROVEMENTS: BUG FIXES: * core: Fix restoration of stopped periodic jobs [GH-3201] * core: Run deployment garbage collector on an interval [GH-3267] + * core: Fix paramterized jobs occasionally showing status dead incorrectly + [GH-3460] * core: Fix issue in which job versions above a threshold potentially wouldn't be stored [GH-3372] * core: Fix issue where node-drain with complete batch allocation would create