in proxy/lib/proxy/proxy.go [306:325]
func (s *Service) unlockFetchAccessTokenForSA(ctx context.Context) {
// call this only if you do not already hold the fetch lock.
s.gcpAccessTokenFetchLock.Lock()
defer s.gcpAccessTokenFetchLock.Unlock()
now := time.Now()
// don't prefetch if there is a recent token refresh in flight.
if now.Before(s.gcpAccessLastRequestStarted.Add(gcpAccessTokenFetchInterval)) {
return
}
s.gcpAccessLastRequestStarted = now
tok, expire, err := s.fetchAccessTokenForSA(ctx)
if err != nil {
glog.Errorf("unable to fetch access token for SA, maybe iam/credentials experincing issue: %v", err)
return
}
s.lockedUpdateToken(tok, expire)
}