in internal/credsretriever/refreshing_cache.go [193:215]
func (r *cachedCredentialRetriever) callDelegateAndCache(ctx context.Context,
request *credentials.EksCredentialsRequest) (cacheEntry, credentials.ResponseMetadata, error) {
log := logger.FromContext(ctx)
newCacheEntry, err := r.fetchCredentialsFromDelegate(ctx, request)
if err != nil {
return cacheEntry{}, nil, fmt.Errorf("error getting credentials to cache: %w", err)
}
credsDuration, credentialsValid := r.credentialsInEntryWithinValidTtl(newCacheEntry)
if !credentialsValid {
return cacheEntry{}, nil, fmt.Errorf("fetched credentials are expired or will expire within the next %0.2f seconds", credsDuration.Seconds())
}
refreshTtl := minDuration(credsDuration, r.credentialsRenewalTtl)
log.WithField("refreshTtl", refreshTtl).Infof("Storing creds in cache")
// Store credentials in cache if they are valid. It might be that
// the credentials might have been either removed or inserted by another
// thread, but it won't matter, we'll just upsert as the cache is thread safe
r.internalCache.SetWithRefreshExpire(request.ServiceAccountToken, newCacheEntry, refreshTtl, credsDuration)
return newCacheEntry, nil, nil
}