Skip to content

Commit

Permalink
Added -allow-stale option into deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanov1609 committed Jun 9, 2018
1 parent b3f596a commit a43fc95
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 @@ -68,6 +68,9 @@ General Options:
-var-file=<file>
Used in conjunction with the -job-file will deploy a templated job to your
Nomad cluster. [default: levant.(yaml|yml|tf)]
-allow-stale
Allow stale consistency mode for requests into nomad.
`
return strings.TrimSpace(helpText)
}
Expand Down Expand Up @@ -95,6 +98,7 @@ func (c *DeployCommand) Run(args []string) int {
flags.StringVar(&config.LogLevel, "log-level", "INFO", "")
flags.StringVar(&config.LogFormat, "log-format", "HUMAN", "")
flags.StringVar(&config.VaiableFile, "var-file", "", "")
flags.BoolVar(&config.AllowStale, "allow-stale", false, "")

if err = flags.Parse(args); err != nil {
return 1
Expand Down
4 changes: 2 additions & 2 deletions levant/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,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 @@ -372,7 +372,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 @@ -43,4 +43,7 @@ type Config struct {
// VaiableFile contains the variables which will be substituted into the
// templateFile before deployment.
VaiableFile string

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

0 comments on commit a43fc95

Please sign in to comment.