@@ -82,16 +82,18 @@ func NewClientWithToken(cfg *ClientConfig, token string) (*Client, error) {
82
82
func (c * Client ) startTokenLifecycleManager (initialLoginDone chan struct {}) {
83
83
defer func () {
84
84
// make sure to close channel to avoid blocking of the caller
85
- _ , open := <- initialLoginDone
86
- if open {
87
- close (initialLoginDone )
88
- }
85
+ log .Entry ().Debugf ("exiting Vault token lifecycle manager" )
86
+ initialLoginDone <- struct {}{}
87
+ close (initialLoginDone )
89
88
}()
90
89
91
90
initialLoginSucceed := false
92
- for i := 0 ; i < c .vaultApiClient .MaxRetries (); i ++ {
91
+ retryAttemptDuration := c .vaultApiClient .MinRetryWait ()
92
+ for i := 0 ; i <= c .vaultApiClient .MaxRetries (); i ++ {
93
93
if i != 0 {
94
- log .Entry ().Infof ("Retrying Vault login. Attempt %d of %d" , i , c .vaultApiClient .MaxRetries ())
94
+ log .Entry ().Infof ("Retrying Vault login in %.0f seconds. Attempt %d of %d" ,
95
+ retryAttemptDuration .Seconds (), i , c .vaultApiClient .MaxRetries ())
96
+ time .Sleep (retryAttemptDuration )
95
97
}
96
98
97
99
vaultLoginResp , err := c .login ()
@@ -101,7 +103,6 @@ func (c *Client) startTokenLifecycleManager(initialLoginDone chan struct{}) {
101
103
}
102
104
if ! initialLoginSucceed {
103
105
initialLoginDone <- struct {}{}
104
- close (initialLoginDone )
105
106
initialLoginSucceed = true
106
107
}
107
108
0 commit comments