Skip to content

Commit c77c5a0

Browse files
authored
Merge pull request #2102 from mattcary/hash
Print cluster hash for GKE k8s integration tests
2 parents 4d3052b + a8040f9 commit c77c5a0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/k8s-integration/cluster.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"bufio"
45
"encoding/json"
56
"errors"
67
"fmt"
@@ -280,6 +281,26 @@ func clusterUpGKE(gceZone, gceRegion string, numNodes int, numWindowsNodes int,
280281
}
281282
}
282283

284+
cmd = exec.Command("gcloud", "container", "clusters", "describe", *gkeTestClusterName, locationArg, locationVal)
285+
out, err = cmd.CombinedOutput()
286+
if err != nil {
287+
return fmt.Errorf("failed to list cluster: %v %s", err, out)
288+
}
289+
scanner := bufio.NewScanner(strings.NewReader(string(out)))
290+
printedHash := false
291+
for scanner.Scan() {
292+
line := scanner.Text()
293+
if strings.HasPrefix(line, "id: ") {
294+
klog.Infof("GKE cluster: %s %s", *gkeTestClusterName, locationVal)
295+
klog.Infof("GKE cluster hash %s", line)
296+
printedHash = true
297+
break
298+
}
299+
}
300+
if !printedHash {
301+
return fmt.Errorf("failed to find cluster hash in cluster describe: %s", out)
302+
}
303+
283304
return nil
284305
}
285306

0 commit comments

Comments
 (0)