Skip to content

Commit

Permalink
Merge pull request #106 from jrasell/b_gh_105
Browse files Browse the repository at this point in the history
Ensure the count updater ignores jobs that are in stopped state.
  • Loading branch information
jrasell committed Feb 8, 2018
2 parents 1c3501e + cda88d1 commit 02d1f8a
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit 02d1f8a

Please sign in to comment.