From a8040f9782386f897d72ac2b7076078dc8de8c15 Mon Sep 17 00:00:00 2001 From: Matthew Cary Date: Thu, 29 May 2025 18:02:18 +0000 Subject: [PATCH] Print cluster hash for GKE k8s integration tests Change-Id: Id9befb7508b785ed1fe96efff48c5fa84a6f1d1a --- test/k8s-integration/cluster.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 }