Skip to content

Commit

Permalink
Merge branch 'master' into fix_nilpointer_deref
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasell committed Nov 15, 2017
2 parents bd44a2c + abfcb4d commit 41a343e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 0.0.2 (Unreleased)

IMPROVEMENTS:
* Introduce `-force-count` flag into deploy command which disables dynamic count updating; meaning Levant will explicity use counts defined in the job specification template [GH-33](https://github.com/jrasell/levant/pull/33)

BUG FIXES:
* Fix formatting issue in render command help [GH-28](https://github.com/jrasell/levant/pull/28)
* Update failure_inspector to cover more failure use cases [GH-27](https://github.com/jrasell/levant/pull/27)
Expand Down
8 changes: 7 additions & 1 deletion command/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ General Options:
-var-file=<file>
Used in conjunction with the -job-file will deploy a templated job to your
Nomad cluster.
-force-count
Use the taskgroup count from the Nomad jobfile instead of the count that
is currently set in a running job.
`
return strings.TrimSpace(helpText)
}
Expand All @@ -57,6 +61,7 @@ func (c *DeployCommand) Run(args []string) int {
var err error
var job *nomad.Job
var canary int
var forceCount bool

flags := c.Meta.FlagSet("deploy", FlagSetVars)
flags.Usage = func() { c.UI.Output(c.Help()) }
Expand All @@ -65,6 +70,7 @@ func (c *DeployCommand) Run(args []string) int {
flags.IntVar(&canary, "canary-auto-promote", 0, "")
flags.StringVar(&log, "log-level", "INFO", "")
flags.StringVar(&variables, "var-file", "", "")
flags.BoolVar(&forceCount, "force-count", false, "")

if err = flags.Parse(args); err != nil {
return 1
Expand Down Expand Up @@ -98,7 +104,7 @@ func (c *DeployCommand) Run(args []string) int {
return 1
}

success := client.Deploy(job, canary)
success := client.Deploy(job, canary, forceCount)
if !success {
c.UI.Error(fmt.Sprintf("[ERROR] levant/command: deployment of job %s failed", *job.Name))
return 1
Expand Down
12 changes: 7 additions & 5 deletions levant/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type nomadClient struct {
type NomadClient interface {
// Deploy triggers a register of the job resulting in a Nomad deployment which
// is monitored to determine the eventual state.
Deploy(*nomad.Job, int) bool
Deploy(*nomad.Job, int, bool) bool
}

// NewNomadClient is used to create a new client to interact with Nomad.
Expand All @@ -39,7 +39,7 @@ func NewNomadClient(addr string) (NomadClient, error) {

// Deploy triggers a register of the job resulting in a Nomad deployment which
// is monitored to determine the eventual state.
func (c *nomadClient) Deploy(job *nomad.Job, autoPromote int) (success bool) {
func (c *nomadClient) Deploy(job *nomad.Job, autoPromote int, forceCount bool) (success bool) {

// Validate the job to check it is syntactically correct.
if _, _, err := c.nomad.Jobs().Validate(job, nil); err != nil {
Expand All @@ -53,9 +53,11 @@ func (c *nomadClient) Deploy(job *nomad.Job, autoPromote int) (success bool) {
return
}

logging.Debug("levant/deploy: running dynamic job count updater for job %s", *job.Name)
if err := c.dynamicGroupCountUpdater(job); err != nil {
return
if !forceCount {
logging.Debug("levant/deploy: running dynamic job count updater for job %s", *job.Name)
if err := c.dynamicGroupCountUpdater(job); err != nil {
return
}
}

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

0 comments on commit 41a343e

Please sign in to comment.