Skip to content

Commit

Permalink
vault: ensure SetConfig calls are serialized
Browse files Browse the repository at this point in the history
This is a defensive measure as SetConfig should only be called serially.
  • Loading branch information
schmichael committed Aug 6, 2019
1 parent 7e08a2f commit 2175301
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nomad/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ type vaultClient struct {
// l is used to lock the configuration aspects of the client such that
// multiple callers can't cause conflicting config updates
l sync.Mutex

// setConfigLock serializes access to the SetConfig method
setConfigLock sync.Mutex
}

// NewVaultClient returns a Vault client from the given config. If the client
Expand Down Expand Up @@ -330,6 +333,8 @@ func (v *vaultClient) SetConfig(config *config.VaultConfig) error {
if config == nil {
return fmt.Errorf("must pass valid VaultConfig")
}
v.setConfigLock.Lock()
defer v.setConfigLock.Unlock()

v.l.Lock()
defer v.l.Unlock()
Expand Down

0 comments on commit 2175301

Please sign in to comment.