Skip to content

Commit

Permalink
Merge pull request #3460 from hashicorp/b-param-status
Browse files Browse the repository at this point in the history
Bypass status checks for system, periodic, parameterized jobs
  • Loading branch information
dadgar committed Oct 27, 2017
2 parents c851c51 + e45f83d commit 35f11f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 10 additions & 21 deletions nomad/state/state_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 35f11f7

Please sign in to comment.