Skip to content

Commit 33e82c5

Browse files
committed
PGO CLI Version Self-Reporting
This commmit adds the PGO CLI version to the information collected by the support export command. Issue: [sc-18016]
1 parent a6b8e22 commit 33e82c5

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

internal/cmd/export.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,14 @@ kubectl pgo support export daisy --monitoring-namespace another-namespace --outp
270270
}()
271271

272272
// TODO (jmckulk): collect context info
273-
// TODO (jmckulk): collect client version, after pgo version command is implemented
273+
274+
// PGO CLI version
275+
err = gatherPGOCLIVersion(ctx, clusterName, tw, cmd)
274276

275277
// Gather cluster wide resources
276-
err = gatherKubeServerVersion(ctx, discoveryClient, clusterName, tw, cmd)
278+
if err == nil {
279+
err = gatherKubeServerVersion(ctx, discoveryClient, clusterName, tw, cmd)
280+
}
277281

278282
if err == nil {
279283
err = gatherNodes(ctx, clientset, clusterName, tw, cmd)
@@ -357,6 +361,20 @@ func exportSizeReport(size float64) string {
357361
return finalMsg
358362
}
359363

364+
// gatherPGOCLIVersion collects the PGO CLI version
365+
func gatherPGOCLIVersion(_ context.Context,
366+
clusterName string,
367+
tw *tar.Writer,
368+
cmd *cobra.Command,
369+
) error {
370+
371+
path := clusterName + "/pgo-cli-version"
372+
if err := writeTar(tw, []byte(clientVersion), path, cmd); err != nil {
373+
return err
374+
}
375+
return nil
376+
}
377+
360378
// gatherKubeServerVersion collects the server version from the Kubernetes cluster
361379
func gatherKubeServerVersion(_ context.Context,
362380
client *discovery.DiscoveryClient,

internal/cmd/pgo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
)
3030

3131
// store the current PGO CLI version
32-
const clientVersion = "v0.2.0"
32+
const clientVersion = "v0.3.0"
3333

3434
// NewPGOCommand returns the root command of the PGO plugin. This command
3535
// prints the same information as its --help flag: the available subcommands

testing/kuttl/e2e/support-export/01--support_export.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ commands:
77
- script: |
88
#!/bin/bash
99
10-
DIR="./kuttl-support-cluster/nodes/"
11-
LIST="${DIR}list"
12-
1310
CLEANUP="rm -r ./kuttl-support-cluster ./crunchy_k8s_support_export_*.tar.gz"
1411
12+
# check that the PGO CLI version is recorded
13+
VER=$(cat ./kuttl-support-cluster/pgo-cli-version)
14+
[[ "$VER" =~ v[0-9]+.[0-9]+.[0-9]+$ ]] || {
15+
echo "Expected PGO CLI version, got:"
16+
echo "${VER}"
17+
eval "$CLEANUP"
18+
exit 1
19+
}
20+
1521
# check for expected gzip compression level
1622
FILE_INFO=$(file ./crunchy_k8s_support_export_*.tar.gz)
1723
[[ "${FILE_INFO}" == *'gzip compressed data, max compression'* ]] || {
@@ -21,6 +27,10 @@ commands:
2127
exit 1
2228
}
2329
30+
# Node directory and list file path
31+
DIR="./kuttl-support-cluster/nodes/"
32+
LIST="${DIR}list"
33+
2434
# check for expected table header in the list file
2535
KV=$(awk 'NR==1 {print $9}' $LIST)
2636
[[ "${KV}" == '|KERNEL-VERSION' ]] || {

0 commit comments

Comments
 (0)