Skip to content

Commit

Permalink
Merge pull request #48 from eduardogr/eduardogr/47/fixing-renewalLoop…
Browse files Browse the repository at this point in the history
…-function

#47 separating scenarios in renewalLoop
  • Loading branch information
fcgravalos authored Oct 25, 2019
2 parents 965146b + 0dce3db commit 2cce533
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions backend/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,16 @@ func (c *client) renewalLoop() {
c.logger.Info("trying to login to vault again")
if err = c.vaultLogin(); err != nil {
vMetrics.updateVaultLoginErrorsTotalMetric()
c.logger.Error(err, "login error, vault token not obtained")
} else {
c.logger.Info("login successful, got a new vault token")
}
c.logger.Info("login successful, got a new vault token")
return
}

ttl, err := c.getTokenTTL(token)
if err != nil {
c.logger.Error(err, "failed to read vault token TTL")
return
} else if ttl < c.maxTokenTTL {
c.logger.Info("vault token is really close to expire", "vault_token_ttl", ttl)
err := c.renewToken(token)
Expand All @@ -170,9 +172,8 @@ func (c *client) renewalLoop() {
} else {
c.logger.Info("vault token renewed successfully!")
}
} else {
return
}
return
}

func (c *client) startTokenRenewer(ctx context.Context) {
Expand Down

0 comments on commit 2cce533

Please sign in to comment.