Skip to content

Commit

Permalink
Merge pull request #60 from jrasell/b_gh_56
Browse files Browse the repository at this point in the history
Fix issue where system jobs cause panic.
  • Loading branch information
jrasell committed Dec 8, 2017
2 parents 5c9d290 + 6f33a24 commit f01d4e2
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions levant/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,18 @@ func (c *nomadClient) Deploy(job *nomad.Job, autoPromote int, forceCount bool) (
}
}

// Check that the job has at least 1 TaskGroup with count > 0 (GH-16)
TGCount := 0
for _, group := range job.TaskGroups {
TGCount += *group.Count
}
if TGCount == 0 {
logging.Error("levant/deploy: all TaskGroups have a count of 0, nothing to do")
return
// Check that the job has at least 1 TaskGroup with count > 0 (GH-16) if the
// job is not a System job. Systems jobs do not define counts so cannot be
// checked.
if *job.Type != nomadStructs.JobTypeSystem {
tgCount := 0
for _, group := range job.TaskGroups {
tgCount += *group.Count
}
if tgCount == 0 {
logging.Error("levant/deploy: all TaskGroups have a count of 0, nothing to do")
return
}
}

logging.Info("levant/deploy: triggering a deployment of job %s", *job.Name)
Expand Down

0 comments on commit f01d4e2

Please sign in to comment.