Skip to content

Commit e08c68d

Browse files
committed
Print cluster hash for GKE k8s integration tests
1 parent 84af6e9 commit e08c68d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/k8s-integration/cluster.go

Lines changed: 20 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"
@@ -268,6 +269,25 @@ func clusterUpGKE(gceZone, gceRegion string, numNodes int, numWindowsNodes int,
268269
}
269270
}
270271

272+
out, err := exec.Command("gcloud", "container", "clusters", "describe", *gkeTestClusterName, locationArg, locationVal)
273+
if err != nil {
274+
return fmt.Errorf("failed to list cluster: %v %s", err, out)
275+
}
276+
scanner := bufio.newScanner(strings.NewReader(out))
277+
printedHash := false
278+
for scanner.Scan() {
279+
line := scanner.Text()
280+
if strings.HasPrefix(line, "id: ") {
281+
klog.Infof("%s %s", *gkeTestClusterName, locationVal)
282+
klog.Infof("%s", line)
283+
printedHash = true
284+
break
285+
}
286+
}
287+
if !printedHash {
288+
return fmt.Errorf("failed to find cluster hash in cluster describe: %s", out)
289+
}
290+
271291
return nil
272292
}
273293

0 commit comments

Comments
 (0)