Fix retry of cloudprovider client generation
This commit is contained in:
parent
16a213c076
commit
d59d5c4bf3
1 changed files with 8 additions and 1 deletions
|
@ -17,7 +17,9 @@ limitations under the License.
|
||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
@ -210,12 +212,17 @@ func (c *ClusterManager) GC(lbNames []string, nodePorts []backends.ServicePort)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getGCEClient(config io.Reader) *gce.GCECloud {
|
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
|
// 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.
|
// 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
|
// No errors are thrown. So we need to keep retrying till it works because
|
||||||
// we know we're on GCE.
|
// we know we're on GCE.
|
||||||
for {
|
for {
|
||||||
cloudInterface, err := cloudprovider.GetCloudProvider("gce", config)
|
cloudInterface, err := cloudprovider.GetCloudProvider("gce", bytes.NewReader(allConfig))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
cloud := cloudInterface.(*gce.GCECloud)
|
cloud := cloudInterface.(*gce.GCECloud)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue