Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Redis EntraId Token Refresh #3632

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions common/component/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading