Skip to content

Commit

Permalink
Merge pull request #185 from bogdanov1609/f-allow_stale
Browse files Browse the repository at this point in the history
Added -allow-stale option into deploy
  • Loading branch information
jrasell committed Jul 15, 2018
2 parents d643bbc + 8f4a8b0 commit 778f767
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions command/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ General Options:
The Nomad HTTP API address including port which Levant will use to make
calls.
-allow-stale
Allow stale consistency mode for requests into nomad.
-canary-auto-promote=<seconds>
The time in seconds, after which Levant will auto-promote a canary job
if all canaries within the deployment are healthy.
Expand Down Expand Up @@ -95,6 +98,7 @@ func (c *DeployCommand) Run(args []string) int {
flags.Usage = func() { c.UI.Output(c.Help()) }

flags.StringVar(&config.Addr, "address", "", "")
flags.BoolVar(&config.AllowStale, "allow-stale", false, "")
flags.IntVar(&config.Canary, "canary-auto-promote", 0, "")
flags.StringVar(&addr, "consul-address", "", "")
flags.BoolVar(&config.ForceBatch, "force-batch", false, "")
Expand Down
4 changes: 2 additions & 2 deletions levant/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (l *levantDeployment) deploymentWatcher(depID string) (success bool) {
go l.canaryAutoPromote(depID, l.config.Canary, canaryChan, deploymentChan)
}

q := &nomad.QueryOptions{WaitIndex: 1, AllowStale: true, WaitTime: wt}
q := &nomad.QueryOptions{WaitIndex: 1, AllowStale: l.config.AllowStale, WaitTime: wt}

for {

Expand Down Expand Up @@ -384,7 +384,7 @@ func (l *levantDeployment) checkCanaryDeploymentHealth(depID string) (healthy bo

var unhealthy int

dep, _, err := l.nomad.Deployments().Info(depID, &nomad.QueryOptions{AllowStale: true})
dep, _, err := l.nomad.Deployments().Info(depID, &nomad.QueryOptions{AllowStale: l.config.AllowStale})
if err != nil {
log.Error().Err(err).Msgf("levant/deploy: unable to query deployment %s for health: %v", depID)
return
Expand Down
3 changes: 3 additions & 0 deletions levant/structs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ type Config struct {
// protocol and port.
Addr string

// AllowStale sets consistency level for nomad query - https://www.nomadproject.io/api/index.html#consistency-modes
AllowStale bool

// Canary enables canary autopromote and is the value in seconds to wait
// until attempting to perfrom autopromote.
Canary int
Expand Down

0 comments on commit 778f767

Please sign in to comment.