Skip to content

Commit

Permalink
Merge pull request #1023 from nicksardo/gce-retry-fix
Browse files Browse the repository at this point in the history
GCE: Fix retry of cloudprovider client generation
  • Loading branch information
nicksardo committed Jul 28, 2017
2 parents 08716e5 + d59d5c4 commit 697041a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion controllers/gce/controller/cluster_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ limitations under the License.
package controller

import (
"bytes"
"io"
"io/ioutil"
"net/http"
"os"
"time"
Expand Down Expand Up @@ -210,12 +212,17 @@ func (c *ClusterManager) GC(lbNames []string, nodePorts []backends.ServicePort)
}

func getGCEClient(config io.Reader) *gce.GCECloud {
allConfig, err := ioutil.ReadAll(config)
if err != nil {
glog.Fatalf("Error while reading entire config: %v", err)
}

// Creating the cloud interface involves resolving the metadata server to get
// an oauth token. If this fails, the token provider assumes it's not on GCE.
// No errors are thrown. So we need to keep retrying till it works because
// we know we're on GCE.
for {
cloudInterface, err := cloudprovider.GetCloudProvider("gce", config)
cloudInterface, err := cloudprovider.GetCloudProvider("gce", bytes.NewReader(allConfig))
if err == nil {
cloud := cloudInterface.(*gce.GCECloud)

Expand Down

0 comments on commit 697041a

Please sign in to comment.