Skip to content

Commit

Permalink
changed how throttle works
Browse files Browse the repository at this point in the history
  • Loading branch information
lwahlmeier committed Feb 11, 2021
1 parent 2068d58 commit fcdbbed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Stim Changelog

## 0.3.1
### Improvements
* changed thottle to 5 times and 2/4/8/16/32 sec
### Bugfix
* still fail if throttling happens more then 5 times


## 0.3.0
### Improvements
* Allow vault to retry getting AWS creditials on throttle message: `vault.retryOnThrottle:bool`
Expand Down
9 changes: 6 additions & 3 deletions stim/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,26 @@ func (stim *Stim) Env(config *EnvConfig) *env.Env {
v2e.SetVaultToken(vaultToken)
v2e.AddSecretItems(config.Vault.SecretItems...)

sleepTime := time.Duration(time.Second)
sleepTime := time.Duration(time.Second * 2)

var secretEnvs []string

for i := 0; i < 3; i++ {
for i := 0; i < 5; i++ {
secretEnvs, err = v2e.GetEnvs()
if err != nil {
if stim.ConfigGetBool("vault.retryOnThrottle") && strings.Contains(err.Error(), "Throttling: Rate exceeded") {
stim.log.Info("Stim: Got Throttling error waiting {} then trying again, try number:{}", sleepTime, i+1)
time.Sleep(sleepTime)
sleepTime += time.Duration(time.Second)
sleepTime += sleepTime
continue
}
stim.log.Fatal("Stim: Unable to get Vault secrets for environment. {}", err)
}
break
}
if err != nil {
stim.log.Fatal("Stim: Unable to get Vault secrets for environment. {}", err)
}

e.AddEnvVars(secretEnvs...)
}
Expand Down

0 comments on commit fcdbbed

Please sign in to comment.