From 95b2219bc3d82b1a7e5c35c681fdf7ebebbc6959 Mon Sep 17 00:00:00 2001 From: Andreas Auernhammer Date: Mon, 13 Jan 2025 14:10:12 +0100 Subject: [PATCH] vault: reset token TTL to 0 when renewing token This commit resets the token TTL to zero once we start another re-authentication attempt. The reason is that if we fail to re-authenticate, we should not wait again for 80% of the prev. token TTL but instead re-authenticate right away. Signed-off-by: Andreas Auernhammer --- internal/keystore/vault/client.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/keystore/vault/client.go b/internal/keystore/vault/client.go index f34aee52..9df392da 100644 --- a/internal/keystore/vault/client.go +++ b/internal/keystore/vault/client.go @@ -196,6 +196,7 @@ func (c *client) RenewToken(ctx context.Context, authenticate authFunc, secret * } renewIn := 80 * (ttl / 100) // Renew token after 80% of its TTL has passed + ttl = 0 // Set TTL to zero to trigger an immediate re-authentication in case of auth failure select { case <-ctx.Done(): return