diff --git a/test/k8s-integration/cluster.go b/test/k8s-integration/cluster.go index 6f87050d7..9f15c3250 100644 --- a/test/k8s-integration/cluster.go +++ b/test/k8s-integration/cluster.go @@ -1,6 +1,7 @@ package main import ( + "bufio" "encoding/json" "errors" "fmt" @@ -268,6 +269,26 @@ func clusterUpGKE(gceZone, gceRegion string, numNodes int, numWindowsNodes int, } } + cmd = exec.Command("gcloud", "container", "clusters", "describe", *gkeTestClusterName, locationArg, locationVal) + out, err = cmd.CombinedOutput() + if err != nil { + return fmt.Errorf("failed to list cluster: %v %s", err, out) + } + scanner := bufio.NewScanner(strings.NewReader(string(out))) + printedHash := false + for scanner.Scan() { + line := scanner.Text() + if strings.HasPrefix(line, "id: ") { + klog.Infof("GKE cluster: %s %s", *gkeTestClusterName, locationVal) + klog.Infof("GKE cluster hash %s", line) + printedHash = true + break + } + } + if !printedHash { + return fmt.Errorf("failed to find cluster hash in cluster describe: %s", out) + } + return nil }