Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kumactl) return Kuma DP and Envoy version in the output of inspect dataplanes #1298

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion app/kumactl/cmd/inspect/inspect_dataplanes.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func newInspectDataplanesCmd(pctx *inspectContext) *cobra.Command {

func printDataplaneOverviews(now time.Time, dataplaneInsights *mesh_core.DataplaneOverviewResourceList, out io.Writer) error {
data := printers.Table{
Headers: []string{"MESH", "NAME", "TAGS", "STATUS", "LAST CONNECTED AGO", "LAST UPDATED AGO", "TOTAL UPDATES", "TOTAL ERRORS", "CERT REGENERATED AGO", "CERT EXPIRATION", "CERT REGENERATIONS"},
Headers: []string{"MESH", "NAME", "TAGS", "STATUS", "LAST CONNECTED AGO", "LAST UPDATED AGO", "TOTAL UPDATES", "TOTAL ERRORS", "CERT REGENERATED AGO", "CERT EXPIRATION", "CERT REGENERATIONS", "KUMA-DP VERSION", "ENVOY VERSION"},
NextRow: func() func() []string {
i := 0
return func() []string {
Expand Down Expand Up @@ -102,6 +102,17 @@ func printDataplaneOverviews(now time.Time, dataplaneInsights *mesh_core.Datapla
dataplaneInsight.GetMTLS().GetCertificateExpirationTime()
certRegenerations := strconv.Itoa(int(dataplaneInsight.GetMTLS().GetCertificateRegenerations()))

var kumaDpVersion string
var envoyVersion string
if lastSubscription.Version != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastSubscription.GetVersion() which is nil safety version of .Version. Otherwise I saw that

❯❯❯ kumactl inspect dataplanes
MESH   NAME   TAGS   STATUS   LAST CONNECTED AGO   LAST UPDATED AGO   TOTAL UPDATES   TOTAL ERRORS   CERT REGENERATED AGO   CERT EXPIRATION   CERT REGENERATIONS   KUMA-DP VERSION   ENVOY VERSION
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x173aed0]

goroutine 1 [running]:
github.com/kumahq/kuma/app/kumactl/cmd/inspect.printDataplaneOverviews.func1.1(0x0, 0x0, 0x0)
	/Users/jakob/kong/kuma/app/kumactl/cmd/inspect/inspect_dataplanes.go:107 +0x2b0
github.com/kumahq/kuma/app/kumactl/pkg/output/table.(*printer).Print(0x3ee5908, 0xc000bce270, 0xd, 0xd, 0xc000bec660, 0x0, 0x0, 0x2db7540, 0xc00000e018, 0x0, ...)
	/Users/jakob/kong/kuma/app/kumactl/pkg/output/table/printer.go:37 +0xa8
github.com/kumahq/kuma/app/kumactl/cmd/inspect.printDataplaneOverviews(0xbfede8845b03aa28, 0x3ab6861, 0x3ea9760, 0xc0004a1200, 0x2db7540, 0xc00000e018, 0xc000950000, 0xc0004a1200)
	/Users/jakob/kong/kuma/app/kumactl/cmd/inspect/inspect_dataplanes.go:134 +0x22a
github.com/kumahq/kuma/app/kumactl/cmd/inspect.newInspectDataplanesCmd.func1(0xc000b4a2c0, 0x3ee5908, 0x0, 0x0, 0xc000bb7d78, 0xc000bb7d50)
	/Users/jakob/kong/kuma/app/kumactl/cmd/inspect/inspect_dataplanes.go:51 +0x2b7
github.com/kumahq/kuma/app/kumactl/pkg/errors.FormatErrorWrapper.func1(0xc000b4a2c0, 0x3ee5908, 0x0, 0x0, 0x0, 0x0)
	/Users/jakob/kong/kuma/app/kumactl/pkg/errors/formatter.go:14 +0x51
github.com/spf13/cobra.(*Command).execute(0xc000b4a2c0, 0x3ee5908, 0x0, 0x0, 0xc000b4a2c0, 0x3ee5908)
	/Users/jakob/go/pkg/mod/github.com/spf13/[email protected]/command.go:842 +0x47c
github.com/spf13/cobra.(*Command).ExecuteC(0xc000b80580, 0xc000b80580, 0x0, 0x0)
	/Users/jakob/go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/jakob/go/pkg/mod/github.com/spf13/[email protected]/command.go:887
github.com/kumahq/kuma/app/kumactl/cmd.Execute()
	/Users/jakob/kong/kuma/app/kumactl/cmd/root.go:95 +0xa5
main.main()
	/Users/jakob/kong/kuma/app/kumactl/main.go:6 +0x25

for a short moment when DP was up.

Dataplane may not have DataplaneInsight yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

if lastSubscription.Version.KumaDp != nil {
kumaDpVersion = lastSubscription.Version.KumaDp.Version
}
if lastSubscription.Version.Envoy != nil {
envoyVersion = lastSubscription.Version.Envoy.Version
}
}

return []string{
meta.GetMesh(), // MESH
meta.GetName(), // NAME,
Expand All @@ -114,6 +125,8 @@ func printDataplaneOverviews(now time.Time, dataplaneInsights *mesh_core.Datapla
table.Ago(lastCertGeneration, now), // CERT REGENERATED AGO
table.Date(certExpiration), // CERT EXPIRATION
certRegenerations, // CERT REGENERATIONS
kumaDpVersion, // KUMA-DP VERSION
envoyVersion, // ENVOY VERSION
}
}
}(),
Expand Down
24 changes: 24 additions & 0 deletions app/kumactl/cmd/inspect/inspect_dataplanes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ var _ = Describe("kumactl inspect dataplanes", func() {
ResponsesRejected: 1,
},
},
Version: &mesh_proto.Version{
KumaDp: &mesh_proto.KumaDpVersion{
Version: "1.0.0",
GitTag: "v1.0.0",
GitCommit: "91ce236824a9d875601679aa80c63783fb0e8725",
BuildDate: "2019-08-07T11:26:06Z",
},
Envoy: &mesh_proto.EnvoyVersion{
Version: "1.16.0",
Build: "hash/1.16.0/RELEASE",
},
},
},
{
Id: "2",
Expand All @@ -118,6 +130,18 @@ var _ = Describe("kumactl inspect dataplanes", func() {
ResponsesRejected: 2,
},
},
Version: &mesh_proto.Version{
KumaDp: &mesh_proto.KumaDpVersion{
Version: "1.0.2",
GitTag: "v1.0.2",
GitCommit: "9d868cd8681c4021bb4a10bf2306ca613ba4de42",
BuildDate: "2020-08-07T11:26:06Z",
},
Envoy: &mesh_proto.EnvoyVersion{
Version: "1.16.1",
Build: "hash/1.16.1/RELEASE",
},
},
},
},
MTLS: &mesh_proto.DataplaneInsight_MTLS{
Expand Down
24 changes: 24 additions & 0 deletions app/kumactl/cmd/inspect/testdata/inspect-dataplanes.golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
"responsesSent": "10",
"responsesRejected": "1"
}
},
"version": {
"kumaDp": {
"version": "1.0.0",
"gitTag": "v1.0.0",
"gitCommit": "91ce236824a9d875601679aa80c63783fb0e8725",
"buildDate": "2019-08-07T11:26:06Z"
},
"envoy": {
"version": "1.16.0",
"build": "hash/1.16.0/RELEASE"
}
}
},
{
Expand All @@ -47,6 +59,18 @@
"responsesSent": "20",
"responsesRejected": "2"
}
},
"version": {
"kumaDp": {
"version": "1.0.2",
"gitTag": "v1.0.2",
"gitCommit": "9d868cd8681c4021bb4a10bf2306ca613ba4de42",
"buildDate": "2020-08-07T11:26:06Z"
},
"envoy": {
"version": "1.16.1",
"build": "hash/1.16.1/RELEASE"
}
}
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
MESH NAME TAGS STATUS LAST CONNECTED AGO LAST UPDATED AGO TOTAL UPDATES TOTAL ERRORS CERT REGENERATED AGO CERT EXPIRATION CERT REGENERATIONS
default experiment service=metrics,mobile version=v1 Online 2h never 30 3 22h 2020-05-08 08:28:22 10
default example service=example Offline never never 0 0 never - 0
MESH NAME TAGS STATUS LAST CONNECTED AGO LAST UPDATED AGO TOTAL UPDATES TOTAL ERRORS CERT REGENERATED AGO CERT EXPIRATION CERT REGENERATIONS KUMA-DP VERSION ENVOY VERSION
default experiment service=metrics,mobile version=v1 Online 2h never 30 3 22h 2020-05-08 08:28:22 10 1.0.2 1.16.1
default example service=example Offline never never 0 0 never - 0
18 changes: 18 additions & 0 deletions app/kumactl/cmd/inspect/testdata/inspect-dataplanes.golden.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,31 @@ items:
total:
responsesRejected: "1"
responsesSent: "10"
version:
envoy:
build: hash/1.16.0/RELEASE
version: 1.16.0
kumaDp:
buildDate: "2019-08-07T11:26:06Z"
gitCommit: 91ce236824a9d875601679aa80c63783fb0e8725
gitTag: v1.0.0
version: 1.0.0
- connectTime: "2019-07-17T16:05:36.995Z"
controlPlaneInstanceId: node-002
id: "2"
status:
total:
responsesRejected: "2"
responsesSent: "20"
version:
envoy:
build: hash/1.16.1/RELEASE
version: 1.16.1
kumaDp:
buildDate: "2020-08-07T11:26:06Z"
gitCommit: 9d868cd8681c4021bb4a10bf2306ca613ba4de42
gitTag: v1.0.2
version: 1.0.2
mTLS:
certificateExpirationTime: "2020-05-08T08:28:22Z"
certificateRegenerations: 10
Expand Down