Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bypass status checks for system, periodic, parameterized jobs #3460

Merged
merged 2 commits into from
Oct 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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