diff --git a/test/e2e/framework/service_util.go b/test/e2e/framework/service_util.go index ae9edb92d93..a450b36fb0c 100644 --- a/test/e2e/framework/service_util.go +++ b/test/e2e/framework/service_util.go @@ -1368,17 +1368,17 @@ func VerifyServeHostnameServiceDown(c clientset.Interface, host string, serviceI return fmt.Errorf("waiting for service to be down timed out") } -func CleanupServiceResources(c clientset.Interface, loadBalancerName, zone string) { +func CleanupServiceResources(c clientset.Interface, loadBalancerName, region, zone string) { if TestContext.Provider == "gce" || TestContext.Provider == "gke" { - CleanupServiceGCEResources(c, loadBalancerName, zone) + CleanupServiceGCEResources(c, loadBalancerName, region, zone) } // TODO: we need to add this function with other cloud providers, if there is a need. } -func CleanupServiceGCEResources(c clientset.Interface, loadBalancerName, zone string) { +func CleanupServiceGCEResources(c clientset.Interface, loadBalancerName, region, zone string) { if pollErr := wait.Poll(5*time.Second, LoadBalancerCleanupTimeout, func() (bool, error) { - if err := CleanupGCEResources(c, loadBalancerName, zone); err != nil { + if err := CleanupGCEResources(c, loadBalancerName, region, zone); err != nil { Logf("Still waiting for glbc to cleanup: %v", err) return false, nil } diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 60536049d8c..d14bee50fda 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -4868,14 +4868,17 @@ func GetClusterID(c clientset.Interface) (string, error) { // CleanupGCEResources cleans up GCE Service Type=LoadBalancer resources with // the given name. The name is usually the UUID of the Service prefixed with an // alpha-numeric character ('a') to work around cloudprovider rules. -func CleanupGCEResources(c clientset.Interface, loadBalancerName, zone string) (retErr error) { +func CleanupGCEResources(c clientset.Interface, loadBalancerName, region, zone string) (retErr error) { gceCloud, err := GetGCECloud() if err != nil { return err } - region, err := gcecloud.GetGCERegion(zone) - if err != nil { - return fmt.Errorf("error parsing GCE/GKE region from zone %q: %v", zone, err) + if region == "" { + // Attempt to parse region from zone if no region is given. + region, err = gcecloud.GetGCERegion(zone) + if err != nil { + return fmt.Errorf("error parsing GCE/GKE region from zone %q: %v", zone, err) + } } if err := gceCloud.DeleteFirewall(gcecloud.MakeFirewallName(loadBalancerName)); err != nil && !IsGoogleAPIHTTPErrorCode(err, http.StatusNotFound) { diff --git a/test/e2e/network/network_tiers.go b/test/e2e/network/network_tiers.go index 6ae5855b302..6410c517a84 100644 --- a/test/e2e/network/network_tiers.go +++ b/test/e2e/network/network_tiers.go @@ -53,7 +53,7 @@ var _ = SIGDescribe("Services [Feature:GCEAlphaFeature][Slow]", func() { } for _, lb := range serviceLBNames { framework.Logf("cleaning gce resource for %s", lb) - framework.CleanupServiceGCEResources(cs, lb, framework.TestContext.CloudConfig.Zone) + framework.CleanupServiceGCEResources(cs, lb, framework.TestContext.CloudConfig.Region, framework.TestContext.CloudConfig.Zone) } //reset serviceLBNames serviceLBNames = []string{} diff --git a/test/e2e/network/service.go b/test/e2e/network/service.go index 5a2a1e00f6e..42130c7d018 100644 --- a/test/e2e/network/service.go +++ b/test/e2e/network/service.go @@ -61,7 +61,7 @@ var _ = SIGDescribe("Services", func() { } for _, lb := range serviceLBNames { framework.Logf("cleaning gce resource for %s", lb) - framework.CleanupServiceGCEResources(cs, lb, framework.TestContext.CloudConfig.Zone) + framework.CleanupServiceGCEResources(cs, lb, framework.TestContext.CloudConfig.Region, framework.TestContext.CloudConfig.Zone) } //reset serviceLBNames serviceLBNames = []string{} @@ -1555,7 +1555,7 @@ var _ = SIGDescribe("ESIPP [Slow] [DisabledForLargeClusters]", func() { } for _, lb := range serviceLBNames { framework.Logf("cleaning gce resource for %s", lb) - framework.CleanupServiceGCEResources(cs, lb, framework.TestContext.CloudConfig.Zone) + framework.CleanupServiceGCEResources(cs, lb, framework.TestContext.CloudConfig.Region, framework.TestContext.CloudConfig.Zone) } //reset serviceLBNames serviceLBNames = []string{}