Fix Redis EntraId Token Refresh (#3632)

Signed-off-by: Shivam Kumar <shivamkumar@microsoft.com>
Co-authored-by: Shivam Kumar <shivamkumar@microsoft.com>
This commit is contained in:
Shivam Kumar 2024-12-16 22:20:51 +05:30 committed by GitHub
parent 026ae762fa
commit fc8636dbba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -214,21 +214,21 @@ func ParseClientFromProperties(properties map[string]string, componentType metad
// start the token refresh goroutine
if settings.UseEntraID {
StartEntraIDTokenRefreshBackgroundRoutine(c, settings.Username, *tokenExpires, tokenCredential, ctx, logger)
StartEntraIDTokenRefreshBackgroundRoutine(c, settings.Username, *tokenExpires, tokenCredential, logger)
}
return c, &settings, nil
}
func StartEntraIDTokenRefreshBackgroundRoutine(client RedisClient, username string, nextExpiration time.Time, cred *azcore.TokenCredential, parentCtx context.Context, logger *kitlogger.Logger) {
func StartEntraIDTokenRefreshBackgroundRoutine(client RedisClient, username string, nextExpiration time.Time, cred *azcore.TokenCredential, logger *kitlogger.Logger) {
go func(cred *azcore.TokenCredential, username string, logger *kitlogger.Logger) {
ctx, cancel := context.WithCancel(parentCtx)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
backoffConfig := kitretry.DefaultConfig()
backoffConfig.MaxRetries = 3
backoffConfig.Policy = kitretry.PolicyExponential
var backoffManager backoff.BackOff
const refreshGracePeriod = 2 * time.Minute
const refreshGracePeriod = 5 * time.Minute
tokenRefreshDuration := time.Until(nextExpiration.Add(-refreshGracePeriod))
(*logger).Debugf("redis client: starting entraID token refresh loop")