Merge pull request #4456 from JoshVanL/vault-client-health-err-check
Vault internal client should check health conn err before checking response status
This commit is contained in:
commit
5a8b970c97
@ -383,13 +383,25 @@ func (v *Vault) IsVaultInitializedAndUnsealed() error {
|
||||
healthURL := path.Join("/v1", "sys", "health")
|
||||
healthRequest := v.client.NewRequest("GET", healthURL)
|
||||
healthResp, err := v.client.RawRequest(healthRequest)
|
||||
|
||||
if healthResp != nil {
|
||||
defer healthResp.Body.Close()
|
||||
}
|
||||
|
||||
// 429 = if unsealed and standby
|
||||
// 472 = if disaster recovery mode replication secondary and active
|
||||
// 473 = if performance standby
|
||||
if err != nil && healthResp.StatusCode != 429 && healthResp.StatusCode != 472 && healthResp.StatusCode != 473 {
|
||||
return err
|
||||
if err != nil {
|
||||
switch {
|
||||
case healthResp == nil:
|
||||
return err
|
||||
case healthResp.StatusCode == 429, healthResp.StatusCode == 472, healthResp.StatusCode == 473:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("error calling Vault %s: %w", healthURL, err)
|
||||
}
|
||||
}
|
||||
defer healthResp.Body.Close()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user