Skip to content

Commit 0c41f9c

Browse files
authored
fix deadlock and add more logging (#5160)
1 parent 4990b2d commit 0c41f9c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pkg/vault/client.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,18 @@ func NewClientWithToken(cfg *ClientConfig, token string) (*Client, error) {
8282
func (c *Client) startTokenLifecycleManager(initialLoginDone chan struct{}) {
8383
defer func() {
8484
// 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)
8988
}()
9089

9190
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++ {
9393
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)
9597
}
9698

9799
vaultLoginResp, err := c.login()
@@ -101,7 +103,6 @@ func (c *Client) startTokenLifecycleManager(initialLoginDone chan struct{}) {
101103
}
102104
if !initialLoginSucceed {
103105
initialLoginDone <- struct{}{}
104-
close(initialLoginDone)
105106
initialLoginSucceed = true
106107
}
107108

0 commit comments

Comments
 (0)