From 7059717c780efb447e58d611b56de06f5c55a95f Mon Sep 17 00:00:00 2001 From: Joe Finney Date: Tue, 26 Apr 2016 17:39:48 -0700 Subject: [PATCH] Use zone from the test context for static IPs. --- test/e2e/google_compute.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/e2e/google_compute.go b/test/e2e/google_compute.go index c3588b3855e..7a8d144fc39 100644 --- a/test/e2e/google_compute.go +++ b/test/e2e/google_compute.go @@ -25,6 +25,7 @@ import ( "github.com/golang/glog" + "k8s.io/kubernetes/pkg/cloudprovider/providers/gce" "k8s.io/kubernetes/test/e2e/framework" ) @@ -38,13 +39,17 @@ func createGCEStaticIP(name string) (string, error) { // NAME REGION ADDRESS STATUS // test-static-ip us-central1 104.197.143.7 RESERVED - glog.Infof("Creating static IP with name %q in project %q", name, framework.TestContext.CloudConfig.ProjectID) var outputBytes []byte var err error + region, err := gce.GetGCERegion(framework.TestContext.CloudConfig.Zone) + if err != nil { + return "", fmt.Errorf("failed to convert zone to region: %v", err) + } + glog.Infof("Creating static IP with name %q in project %q in region %q", name, framework.TestContext.CloudConfig.ProjectID, region) for attempts := 0; attempts < 4; attempts++ { outputBytes, err = exec.Command("gcloud", "compute", "addresses", "create", name, "--project", framework.TestContext.CloudConfig.ProjectID, - "--region", "us-central1", "-q").CombinedOutput() + "--region", region, "-q").CombinedOutput() if err == nil { break } @@ -77,9 +82,14 @@ func deleteGCEStaticIP(name string) error { // NAME REGION ADDRESS STATUS // test-static-ip us-central1 104.197.143.7 RESERVED + region, err := gce.GetGCERegion(framework.TestContext.CloudConfig.Zone) + if err != nil { + return fmt.Errorf("failed to convert zone to region: %v", err) + } + glog.Infof("Deleting static IP with name %q in project %q in region %q", name, framework.TestContext.CloudConfig.ProjectID, region) outputBytes, err := exec.Command("gcloud", "compute", "addresses", "delete", name, "--project", framework.TestContext.CloudConfig.ProjectID, - "--region", "us-central1", "-q").CombinedOutput() + "--region", region, "-q").CombinedOutput() if err != nil { // Ditch the error, since the stderr in the output is what actually contains // any useful info.