Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
- Log error on each retry
- Do not return error from PollUntilContextTimeout condition func
- Reduce retry interval to 10 seconds to match historical behavior
  • Loading branch information
TheRealJon committed Feb 22, 2024
1 parent 9761d5f commit 5f03015
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/auth/asynccache.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

const (
initializationRetryInterval = 30 * time.Second
initializationRetryInterval = 10 * time.Second
initializationTimeout = 5 * time.Minute
initializeImmediately = true
)
Expand All @@ -33,16 +33,17 @@ func NewAsyncCache[T any](ctx context.Context, reloadPeriod time.Duration, cachi
cachingFunc: cachingFunc,
}

err := wait.PollUntilContextTimeout(
var err error
wait.PollUntilContextTimeout(
ctx,
initializationRetryInterval,
initializationTimeout,
initializeImmediately,
func(ctx context.Context) (bool, error) {
item, err := cachingFunc(ctx)
if err != nil {
klog.V(4).Infof("failed to setup an async cache - retrying in %s", initializationRetryInterval)
return false, err
klog.V(4).Infof("failed to setup an async cache (retrying in %v) - caching func returned error: %v", initializationRetryInterval, err)
return false, nil
}
c.cachedItem = item
return true, nil
Expand Down

0 comments on commit 5f03015

Please sign in to comment.