mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
retry oauth token fetch in gce cloudprovider
The ouath client fetches a token on it's first request. Let's warm the cache to avoid pesky flakes.
This commit is contained in:
parent
83035a52ce
commit
1a3ff0788b
@ -28,8 +28,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gopkg.in/gcfg.v1"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
apiservice "k8s.io/kubernetes/pkg/api/service"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
@ -48,6 +46,7 @@ import (
|
||||
container "google.golang.org/api/container/v1"
|
||||
"google.golang.org/api/googleapi"
|
||||
"google.golang.org/cloud/compute/metadata"
|
||||
"gopkg.in/gcfg.v1"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -326,6 +325,16 @@ func CreateGCECloud(projectID, region, zone string, managedZones []string, netwo
|
||||
glog.Infof("Using existing Token Source %#v", tokenSource)
|
||||
}
|
||||
|
||||
if err := wait.PollImmediate(5*time.Second, 30*time.Second, func() (bool, error) {
|
||||
if _, err := tokenSource.Token(); err != nil {
|
||||
glog.Errorf("error fetching initial token: %v", err)
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := oauth2.NewClient(oauth2.NoContext, tokenSource)
|
||||
svc, err := compute.New(client)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user