From 74bd4d643a7a0b74a831d4e8f9ce38fe138a0123 Mon Sep 17 00:00:00 2001 From: Joachim Bartosik Date: Thu, 24 Jan 2019 15:26:10 +0100 Subject: [PATCH] Detect zone of MIG in e2e VPA tests I was running e2e VPA tests and some were failing because the tests assume thata they're running on: - zonal single-zone cluster, or - regional multi-zone cluster. And I was running them on regional, single-zoned cluster. Change-Id: I110a70d2249f981b60cf76d1ad674ccfcedd8fb3 --- test/e2e/framework/providers/gce/gce.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/test/e2e/framework/providers/gce/gce.go b/test/e2e/framework/providers/gce/gce.go index 472d57f0b4a..4758b5091a1 100644 --- a/test/e2e/framework/providers/gce/gce.go +++ b/test/e2e/framework/providers/gce/gce.go @@ -184,16 +184,12 @@ func (p *Provider) EnsureLoadBalancerResourcesDeleted(ip, portRange string) erro } func getGCEZoneForGroup(group string) (string, error) { - zone := framework.TestContext.CloudConfig.Zone - if framework.TestContext.CloudConfig.MultiZone { - output, err := exec.Command("gcloud", "compute", "instance-groups", "managed", "list", - "--project="+framework.TestContext.CloudConfig.ProjectID, "--format=value(zone)", "--filter=name="+group).CombinedOutput() - if err != nil { - return "", fmt.Errorf("Failed to get zone for node group %s: %s", group, output) - } - zone = strings.TrimSpace(string(output)) + output, err := exec.Command("gcloud", "compute", "instance-groups", "managed", "list", + "--project="+framework.TestContext.CloudConfig.ProjectID, "--format=value(zone)", "--filter=name="+group).CombinedOutput() + if err != nil { + return "", fmt.Errorf("Failed to get zone for node group %s: %s", group, output) } - return zone, nil + return strings.TrimSpace(string(output)), nil } // DeleteNode deletes a node which is specified as the argument