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

Ensure the count updater ignores jobs that are in stopped state. #106

Merged
merged 1 commit into from
Feb 8, 2018
Merged
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
9 changes: 8 additions & 1 deletion levant/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func (l *levantDeployment) deploy() (success bool) {
}

if !l.config.ForceCount {
logging.Debug("levant/deploy: running dynamic job count updater for job %s", *l.config.Job.Name)
if err := l.dynamicGroupCountUpdater(); err != nil {
return
}
Expand Down Expand Up @@ -412,6 +411,12 @@ func (l *levantDeployment) dynamicGroupCountUpdater() error {
// Nomad cluster.
rJob, _, err := l.nomad.Jobs().Info(*l.config.Job.Name, &nomad.QueryOptions{})

// Check that the job is actually running and not in a potentially stopped
// state.
if *rJob.Status != nomadStructs.JobStatusRunning {
return nil
}

// This is a hack due to GH-1849; we check the error string for 404 which
// indicates the job is not running, not that there was an error in the API
// call.
Expand All @@ -423,6 +428,8 @@ func (l *levantDeployment) dynamicGroupCountUpdater() error {
return err
}

logging.Debug("levant/deploy: running dynamic job count updater for job %s", *l.config.Job.Name)

// Iterate the templated job and the Nomad returned job and update group count
// based on matches.
for _, rGroup := range rJob.TaskGroups {
Expand Down