From 2b70c9ec44f753fd51e4e595e8cfb8ba9b49f615 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Thu, 12 Jul 2018 18:38:18 -0400 Subject: [PATCH] Turn off retries on CLI (#4918) For the CLI it just ends up confusing people as to why it's "hanging" before returning a 500. This can still be overridden with VAULT_MAX_RETRIES. --- command/base.go | 6 ++++++ command/base_predict.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/command/base.go b/command/base.go index 79f8cf40a9..e0381267d4 100644 --- a/command/base.go +++ b/command/base.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "io/ioutil" + "os" "regexp" "strings" "sync" @@ -88,6 +89,11 @@ func (c *BaseCommand) Client() (*api.Client, error) { return nil, errors.Wrap(err, "failed to create client") } + // Turn off retries on the CLI + if os.Getenv(api.EnvVaultMaxRetries) == "" { + client.SetMaxRetries(0) + } + // Set the wrapping function client.SetWrappingLookupFunc(c.DefaultWrappingLookupFunc) diff --git a/command/base_predict.go b/command/base_predict.go index 4897ad6c05..a280b86e0b 100644 --- a/command/base_predict.go +++ b/command/base_predict.go @@ -1,6 +1,7 @@ package command import ( + "os" "sort" "strings" "sync" @@ -35,6 +36,11 @@ func (p *Predict) Client() *api.Client { client.SetToken(token) } + // Turn off retries for prediction + if os.Getenv(api.EnvVaultMaxRetries) == "" { + client.SetMaxRetries(0) + } + p.client = client } })