From a43fc9501a2e8ed064f5fc70de5053e7b7402e3c Mon Sep 17 00:00:00 2001 From: Ivan Bogdanov Date: Sat, 9 Jun 2018 15:42:31 +0300 Subject: [PATCH] Added -allow-stale option into deploy --- command/deploy.go | 4 ++++ levant/deploy.go | 4 ++-- levant/structs/config.go | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/command/deploy.go b/command/deploy.go index eae306e51..49bd2991a 100644 --- a/command/deploy.go +++ b/command/deploy.go @@ -68,6 +68,9 @@ General Options: -var-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) } @@ -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 diff --git a/levant/deploy.go b/levant/deploy.go index d6b2ad995..05bf9cab8 100644 --- a/levant/deploy.go +++ b/levant/deploy.go @@ -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 { @@ -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 diff --git a/levant/structs/config.go b/levant/structs/config.go index 1eec53f77..6df33c2f7 100644 --- a/levant/structs/config.go +++ b/levant/structs/config.go @@ -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 }