From 19560293d3f67934e29f08be9c59d5632ef959e9 Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Tue, 10 Nov 2020 18:16:35 +0530 Subject: [PATCH 01/11] cli: reorganise diagnostics subcommand Fixes #5192 This PR moves `metrics`, `diagnostics`(which prints out metrics of control-plane components) and `endpoints` into a new `diagnostics` subcommand. Signed-off-by: Tarun Pothulapati --- cli/cmd/diagnostics.go | 47 ++++++++++++++++---- cli/cmd/endpoints.go | 8 ++-- cli/cmd/metrics.go | 8 ++-- cli/cmd/root.go | 2 - test/integration/endpoints/endpoints_test.go | 1 + 5 files changed, 47 insertions(+), 19 deletions(-) diff --git a/cli/cmd/diagnostics.go b/cli/cmd/diagnostics.go index d15251efaffed..8405bd7adcbc5 100644 --- a/cli/cmd/diagnostics.go +++ b/cli/cmd/diagnostics.go @@ -14,28 +14,57 @@ const ( adminHTTPPortName string = "admin-http" ) -// diagnosticsOptions holds values for command line flags that apply to the diagnostics +// ControlPlaneMetricsOptions holds values for command line flags that apply to the controlplane-metrics // command. -type diagnosticsOptions struct { +type ControlPlaneMetricsOptions struct { wait time.Duration } -// newDiagnosticsOptions initializes diagnostics options setting -// the max wait time duration as 30 seconds to fetch diagnostics +// newControlPlaneMetricsOptions initializes controlplane-metrics options setting +// the max wait time duration as 30 seconds to fetch controlplane-metrics // // This option may be overridden on the CLI at run-time -func newDiagnosticsOptions() *diagnosticsOptions { - return &diagnosticsOptions{ +func newControlPlaneMetricsOptions() *ControlPlaneMetricsOptions { + return &ControlPlaneMetricsOptions{ wait: 30 * time.Second, } } -// newCmdDashboard creates a new cobra command `diagnostics` which contains commands to fetch control plane container's metrics +// newCmdDiagnostics creates a new cobra command `diagnostics` which contains commands to diagnose Linkerd func newCmdDiagnostics() *cobra.Command { - options := newDiagnosticsOptions() + + diagnosticsCmd := &cobra.Command{ + Use: "diagnostics [flags]", + Aliases: []string{"dg"}, + Args: cobra.NoArgs, + Short: "Commands used to diagnose Linkerd components", + Long: `Commands used to diagnose Linkerd components. + +This command provides subcommands to diagnose the functionality of Linkerd.`, + Example: ` # Get control-plane component metrics + linkerd diagnostics cp-metrics + + # Get metrics from the web deployment in the emojivoto namespace. + linkerd diagnostics proxy-metrics -n emojivoto deploy/web + + # get the endpoints for authorities in Linkerd's control-plane itself + linkerd diagnostics endpoints linkerd-controller-api.linkerd.svc.cluster.local:8085 + `, + } + + diagnosticsCmd.AddCommand(newCmdControlPlaneMetrics()) + diagnosticsCmd.AddCommand(newCmdEndpoints()) + diagnosticsCmd.AddCommand(newCmdMetrics()) + return diagnosticsCmd +} + +// newCmdControlPlaneMetrics creates a new cobra command `controlplane-metrics` which contains commands to fetch control plane container's metrics +func newCmdControlPlaneMetrics() *cobra.Command { + options := newControlPlaneMetricsOptions() cmd := &cobra.Command{ - Use: "diagnostics", + Use: "controlplane-metrics", + Aliases: []string{"cp-metrics"}, Short: "Fetch metrics directly from the Linkerd control plane containers", Long: `Fetch metrics directly from Linkerd control plane containers. diff --git a/cli/cmd/endpoints.go b/cli/cmd/endpoints.go index cff6abc6a0a21..47b63bac997bc 100644 --- a/cli/cmd/endpoints.go +++ b/cli/cmd/endpoints.go @@ -58,14 +58,14 @@ func newCmdEndpoints() *cobra.Command { options := newEndpointsOptions() example := ` # get all endpoints for the authorities emoji-svc.emojivoto.svc.cluster.local:8080 and web-svc.emojivoto.svc.cluster.local:80 - linkerd endpoints emoji-svc.emojivoto.svc.cluster.local:8080 web-svc.emojivoto.svc.cluster.local:80 + linkerd diagnostics endpoints emoji-svc.emojivoto.svc.cluster.local:8080 web-svc.emojivoto.svc.cluster.local:80 # get that same information in json format - linkerd endpoints -o json emoji-svc.emojivoto.svc.cluster.local:8080 web-svc.emojivoto.svc.cluster.local:80 + linkerd diagnostics endpoints -o json emoji-svc.emojivoto.svc.cluster.local:8080 web-svc.emojivoto.svc.cluster.local:80 # get the endpoints for authorities in Linkerd's control-plane itself - linkerd endpoints linkerd-controller-api.linkerd.svc.cluster.local:8085 - linkerd endpoints linkerd-web.linkerd.svc.cluster.local:8084` + linkerd diagnostics endpoints linkerd-controller-api.linkerd.svc.cluster.local:8085 + linkerd diagnostics endpoints linkerd-web.linkerd.svc.cluster.local:8084` cmd := &cobra.Command{ Use: "endpoints [flags] authorities", diff --git a/cli/cmd/metrics.go b/cli/cmd/metrics.go index 79679d80e3223..544f2360071ea 100644 --- a/cli/cmd/metrics.go +++ b/cli/cmd/metrics.go @@ -32,7 +32,7 @@ func newCmdMetrics() *cobra.Command { options := newMetricsOptions() cmd := &cobra.Command{ - Use: "metrics [flags] (RESOURCE)", + Use: "proxy-metrics [flags] (RESOURCE)", Short: "Fetch metrics directly from Linkerd proxies", Long: `Fetch metrics directly from Linkerd proxies. @@ -61,13 +61,13 @@ func newCmdMetrics() *cobra.Command { * replicationcontrollers * statefulsets`, Example: ` # Get metrics from pod-foo-bar in the default namespace. - linkerd metrics po/pod-foo-bar + linkerd diagnostics metrics po/pod-foo-bar # Get metrics from the web deployment in the emojivoto namespace. - linkerd metrics -n emojivoto deploy/web + linkerd diagnostics metrics -n emojivoto deploy/web # Get metrics from the linkerd-controller pod in the linkerd namespace. - linkerd metrics -n linkerd $( + linkerd diagnostics metrics -n linkerd $( kubectl --namespace linkerd get pod \ --selector linkerd.io/control-plane-component=controller \ --output name diff --git a/cli/cmd/root.go b/cli/cmd/root.go index b401b33643d18..c563b08434723 100644 --- a/cli/cmd/root.go +++ b/cli/cmd/root.go @@ -112,14 +112,12 @@ func init() { RootCmd.AddCommand(newCmdDiagnostics()) RootCmd.AddCommand(newCmdDoc()) RootCmd.AddCommand(newCmdEdges()) - RootCmd.AddCommand(newCmdEndpoints()) RootCmd.AddCommand(newCmdGet()) RootCmd.AddCommand(newCmdInject()) RootCmd.AddCommand(newCmdInstall()) RootCmd.AddCommand(newCmdInstallCNIPlugin()) RootCmd.AddCommand(newCmdInstallSP()) RootCmd.AddCommand(newCmdLogs()) - RootCmd.AddCommand(newCmdMetrics()) RootCmd.AddCommand(newCmdProfile()) RootCmd.AddCommand(newCmdRoutes()) RootCmd.AddCommand(newCmdStat()) diff --git a/test/integration/endpoints/endpoints_test.go b/test/integration/endpoints/endpoints_test.go index 05609d0cea6cc..2ac724e668c72 100644 --- a/test/integration/endpoints/endpoints_test.go +++ b/test/integration/endpoints/endpoints_test.go @@ -22,6 +22,7 @@ func TestMain(m *testing.M) { func TestGoodEndpoints(t *testing.T) { ns := TestHelper.GetLinkerdNamespace() cmd := []string{ + "diagnostics", "endpoints", fmt.Sprintf("linkerd-controller-api.%s.svc.cluster.local:8085", ns), fmt.Sprintf("linkerd-dst.%s.svc.cluster.local:8086", ns), From f14d984d119ea5ae0ee446f37d6c402f1819e8e9 Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Tue, 10 Nov 2020 18:31:10 +0530 Subject: [PATCH 02/11] linting fix Signed-off-by: Tarun Pothulapati --- cli/cmd/diagnostics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/cmd/diagnostics.go b/cli/cmd/diagnostics.go index 8405bd7adcbc5..2633b54667433 100644 --- a/cli/cmd/diagnostics.go +++ b/cli/cmd/diagnostics.go @@ -63,9 +63,9 @@ func newCmdControlPlaneMetrics() *cobra.Command { options := newControlPlaneMetricsOptions() cmd := &cobra.Command{ - Use: "controlplane-metrics", + Use: "controlplane-metrics", Aliases: []string{"cp-metrics"}, - Short: "Fetch metrics directly from the Linkerd control plane containers", + Short: "Fetch metrics directly from the Linkerd control plane containers", Long: `Fetch metrics directly from Linkerd control plane containers. This command initiates port-forward to each control plane process, and From 0a9bce322f72e6618300c8cbddc23bc12c5b1cde Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Tue, 10 Nov 2020 21:56:39 +0530 Subject: [PATCH 03/11] update integration tests Signed-off-by: Tarun Pothulapati --- test/integration/endpoints/endpoints_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/endpoints/endpoints_test.go b/test/integration/endpoints/endpoints_test.go index 2ac724e668c72..e8bdd044f5953 100644 --- a/test/integration/endpoints/endpoints_test.go +++ b/test/integration/endpoints/endpoints_test.go @@ -55,7 +55,7 @@ func TestGoodEndpoints(t *testing.T) { // TODO: when #3004 gets fixed, add a negative test for mismatched ports func TestBadEndpoints(t *testing.T) { - _, stderr, err := TestHelper.PipeToLinkerdRun("", "endpoints", "foo") + _, stderr, err := TestHelper.PipeToLinkerdRun("", "diagnostics", "endpoints", "foo") if err == nil { testutil.AnnotatedFatalf(t, "was expecting an error", "was expecting an error: %v", err) } From 5f1d3f9c52ac0898954349ce9a10d94b4d166e21 Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Thu, 12 Nov 2020 12:49:20 +0530 Subject: [PATCH 04/11] Update cli/cmd/diagnostics.go better descriotion Co-authored-by: Kevin Leimkuhler --- cli/cmd/diagnostics.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/cmd/diagnostics.go b/cli/cmd/diagnostics.go index 2633b54667433..a7593840ac142 100644 --- a/cli/cmd/diagnostics.go +++ b/cli/cmd/diagnostics.go @@ -30,7 +30,7 @@ func newControlPlaneMetricsOptions() *ControlPlaneMetricsOptions { } } -// newCmdDiagnostics creates a new cobra command `diagnostics` which contains commands to diagnose Linkerd +// newCmdDiagnostics creates a new cobra command `diagnostics` which contains commands to fetch Linkerd diagnostics func newCmdDiagnostics() *cobra.Command { diagnosticsCmd := &cobra.Command{ From b5f1add025717c6ee65d12b4e65458540d0faf8c Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Thu, 12 Nov 2020 13:33:17 +0530 Subject: [PATCH 05/11] rename ControlPlaneMetrics to ControllerMetrics Signed-off-by: Tarun Pothulapati --- cli/cmd/diagnostics.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/cli/cmd/diagnostics.go b/cli/cmd/diagnostics.go index a7593840ac142..5ed00bcff829d 100644 --- a/cli/cmd/diagnostics.go +++ b/cli/cmd/diagnostics.go @@ -14,18 +14,18 @@ const ( adminHTTPPortName string = "admin-http" ) -// ControlPlaneMetricsOptions holds values for command line flags that apply to the controlplane-metrics +// ControllerMetricsOptions holds values for command line flags that apply to the controller-metrics // command. -type ControlPlaneMetricsOptions struct { +type ControllerMetricsOptions struct { wait time.Duration } -// newControlPlaneMetricsOptions initializes controlplane-metrics options setting -// the max wait time duration as 30 seconds to fetch controlplane-metrics +// newControllerMetricsOptions initializes controller-metrics options setting +// the max wait time duration as 30 seconds to fetch controller-metrics // // This option may be overridden on the CLI at run-time -func newControlPlaneMetricsOptions() *ControlPlaneMetricsOptions { - return &ControlPlaneMetricsOptions{ +func newControllerMetricsOptions() *ControllerMetricsOptions { + return &ControllerMetricsOptions{ wait: 30 * time.Second, } } @@ -52,20 +52,19 @@ This command provides subcommands to diagnose the functionality of Linkerd.`, `, } - diagnosticsCmd.AddCommand(newCmdControlPlaneMetrics()) + diagnosticsCmd.AddCommand(newCmdControllerMetrics()) diagnosticsCmd.AddCommand(newCmdEndpoints()) diagnosticsCmd.AddCommand(newCmdMetrics()) return diagnosticsCmd } -// newCmdControlPlaneMetrics creates a new cobra command `controlplane-metrics` which contains commands to fetch control plane container's metrics -func newCmdControlPlaneMetrics() *cobra.Command { - options := newControlPlaneMetricsOptions() +// newCmdControllerMetrics creates a new cobra command `controller-metrics` which contains commands to fetch control plane container's metrics +func newCmdControllerMetrics() *cobra.Command { + options := newControllerMetricsOptions() cmd := &cobra.Command{ - Use: "controlplane-metrics", - Aliases: []string{"cp-metrics"}, - Short: "Fetch metrics directly from the Linkerd control plane containers", + Use: "controller-metrics", + Short: "Fetch metrics directly from the Linkerd control plane containers", Long: `Fetch metrics directly from Linkerd control plane containers. This command initiates port-forward to each control plane process, and From c34a15641a217597482f174c3a089b21e6116584 Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Mon, 22 Feb 2021 16:15:14 +0000 Subject: [PATCH 06/11] move controller-metrics into a separate file Signed-off-by: Tarun Pothulapati --- cli/cmd/controller-metrics.go | 74 +++++++++++++++++++++++++++++++++++ cli/cmd/diagnostics.go | 69 -------------------------------- 2 files changed, 74 insertions(+), 69 deletions(-) create mode 100644 cli/cmd/controller-metrics.go diff --git a/cli/cmd/controller-metrics.go b/cli/cmd/controller-metrics.go new file mode 100644 index 0000000000000..44539cbf09a55 --- /dev/null +++ b/cli/cmd/controller-metrics.go @@ -0,0 +1,74 @@ +package cmd + +import ( + "bytes" + "fmt" + "time" + + "github.com/linkerd/linkerd2/pkg/k8s" + "github.com/spf13/cobra" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ControllerMetricsOptions holds values for command line flags that apply to the controller-metrics +// command. +type ControllerMetricsOptions struct { + wait time.Duration +} + +// newControllerMetricsOptions initializes controller-metrics options setting +// the max wait time duration as 30 seconds to fetch controller-metrics +// +// This option may be overridden on the CLI at run-time +func newControllerMetricsOptions() *ControllerMetricsOptions { + return &ControllerMetricsOptions{ + wait: 30 * time.Second, + } +} + +// newCmdControllerMetrics creates a new cobra command `controller-metrics` which contains commands to fetch control plane container's metrics +func newCmdControllerMetrics() *cobra.Command { + options := newControllerMetricsOptions() + + cmd := &cobra.Command{ + Use: "controller-metrics", + Short: "Fetch metrics directly from the Linkerd control plane containers", + Long: `Fetch metrics directly from Linkerd control plane containers. + + This command initiates port-forward to each control plane process, and + queries the /metrics endpoint on them.`, + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + k8sAPI, err := k8s.NewAPI(kubeconfigPath, kubeContext, impersonate, impersonateGroup, 0) + if err != nil { + return err + } + + pods, err := k8sAPI.CoreV1().Pods(controlPlaneNamespace).List(cmd.Context(), metav1.ListOptions{}) + if err != nil { + return err + } + + results := getMetrics(k8sAPI, pods.Items, adminHTTPPortName, options.wait, verbose) + + var buf bytes.Buffer + for i, result := range results { + content := fmt.Sprintf("#\n# POD %s (%d of %d)\n", result.pod, i+1, len(results)) + if result.err != nil { + content += fmt.Sprintf("# ERROR %s\n", result.err) + } else { + content += fmt.Sprintf("# CONTAINER %s \n#\n", result.container) + content += string(result.metrics) + } + buf.WriteString(content) + } + fmt.Printf("%s", buf.String()) + + return nil + }, + } + + cmd.Flags().DurationVarP(&options.wait, "wait", "w", options.wait, "Time allowed to fetch diagnostics") + + return cmd +} diff --git a/cli/cmd/diagnostics.go b/cli/cmd/diagnostics.go index 5ed00bcff829d..8a417b0c3d01a 100644 --- a/cli/cmd/diagnostics.go +++ b/cli/cmd/diagnostics.go @@ -1,35 +1,13 @@ package cmd import ( - "bytes" - "fmt" - "time" - - "github.com/linkerd/linkerd2/pkg/k8s" "github.com/spf13/cobra" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const ( adminHTTPPortName string = "admin-http" ) -// ControllerMetricsOptions holds values for command line flags that apply to the controller-metrics -// command. -type ControllerMetricsOptions struct { - wait time.Duration -} - -// newControllerMetricsOptions initializes controller-metrics options setting -// the max wait time duration as 30 seconds to fetch controller-metrics -// -// This option may be overridden on the CLI at run-time -func newControllerMetricsOptions() *ControllerMetricsOptions { - return &ControllerMetricsOptions{ - wait: 30 * time.Second, - } -} - // newCmdDiagnostics creates a new cobra command `diagnostics` which contains commands to fetch Linkerd diagnostics func newCmdDiagnostics() *cobra.Command { @@ -57,50 +35,3 @@ This command provides subcommands to diagnose the functionality of Linkerd.`, diagnosticsCmd.AddCommand(newCmdMetrics()) return diagnosticsCmd } - -// newCmdControllerMetrics creates a new cobra command `controller-metrics` which contains commands to fetch control plane container's metrics -func newCmdControllerMetrics() *cobra.Command { - options := newControllerMetricsOptions() - - cmd := &cobra.Command{ - Use: "controller-metrics", - Short: "Fetch metrics directly from the Linkerd control plane containers", - Long: `Fetch metrics directly from Linkerd control plane containers. - - This command initiates port-forward to each control plane process, and - queries the /metrics endpoint on them.`, - Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { - k8sAPI, err := k8s.NewAPI(kubeconfigPath, kubeContext, impersonate, impersonateGroup, 0) - if err != nil { - return err - } - - pods, err := k8sAPI.CoreV1().Pods(controlPlaneNamespace).List(cmd.Context(), metav1.ListOptions{}) - if err != nil { - return err - } - - results := getMetrics(k8sAPI, pods.Items, adminHTTPPortName, options.wait, verbose) - - var buf bytes.Buffer - for i, result := range results { - content := fmt.Sprintf("#\n# POD %s (%d of %d)\n", result.pod, i+1, len(results)) - if result.err != nil { - content += fmt.Sprintf("# ERROR %s\n", result.err) - } else { - content += fmt.Sprintf("# CONTAINER %s \n#\n", result.container) - content += string(result.metrics) - } - buf.WriteString(content) - } - fmt.Printf("%s", buf.String()) - - return nil - }, - } - - cmd.Flags().DurationVarP(&options.wait, "wait", "w", options.wait, "Time allowed to fetch diagnostics") - - return cmd -} From 4fd37fbdacc5a007d141c45987d4b98b81913fc8 Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Mon, 22 Feb 2021 16:47:26 +0000 Subject: [PATCH 07/11] update TestOpaquePorts to include diagnostics prefix Signed-off-by: Tarun Pothulapati --- test/integration/opaqueports/opaque_ports_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/opaqueports/opaque_ports_test.go b/test/integration/opaqueports/opaque_ports_test.go index 28b1afcc5c1c0..b0fb36740b891 100644 --- a/test/integration/opaqueports/opaque_ports_test.go +++ b/test/integration/opaqueports/opaque_ports_test.go @@ -86,7 +86,7 @@ func TestOpaquePorts(t *testing.T) { func getPodMetrics(pod v1.Pod, ns string) (string, error) { podName := fmt.Sprintf("pod/%s", pod.Name) - cmd := []string{"metrics", "--namespace", ns, podName} + cmd := []string{"diagnostics", "proxy-metrics", "--namespace", ns, podName} metrics, err := TestHelper.LinkerdRun(cmd...) if err != nil { return "", err From c7bd5ebdcedc61499fe28d07a4b050c06dcb85e1 Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Tue, 23 Feb 2021 05:14:16 +0000 Subject: [PATCH 08/11] Fix #5193 by moving install-sp under `diagnostics` Signed-off-by: Tarun Pothulapati --- cli/cmd/diagnostics.go | 7 ++++++- cli/cmd/root.go | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cli/cmd/diagnostics.go b/cli/cmd/diagnostics.go index 8a417b0c3d01a..69ab999643400 100644 --- a/cli/cmd/diagnostics.go +++ b/cli/cmd/diagnostics.go @@ -25,13 +25,18 @@ This command provides subcommands to diagnose the functionality of Linkerd.`, # Get metrics from the web deployment in the emojivoto namespace. linkerd diagnostics proxy-metrics -n emojivoto deploy/web - # get the endpoints for authorities in Linkerd's control-plane itself + # Get the endpoints for authorities in Linkerd's control-plane itself linkerd diagnostics endpoints linkerd-controller-api.linkerd.svc.cluster.local:8085 + + # Install service profiles for the control-plane components. + linkerd diagnostics install-sp `, } diagnosticsCmd.AddCommand(newCmdControllerMetrics()) diagnosticsCmd.AddCommand(newCmdEndpoints()) diagnosticsCmd.AddCommand(newCmdMetrics()) + diagnosticsCmd.AddCommand(newCmdInstallSP()) + return diagnosticsCmd } diff --git a/cli/cmd/root.go b/cli/cmd/root.go index 35f640b2a65c8..89efb5d7a4926 100644 --- a/cli/cmd/root.go +++ b/cli/cmd/root.go @@ -107,7 +107,6 @@ func init() { RootCmd.AddCommand(newCmdInject()) RootCmd.AddCommand(newCmdInstall()) RootCmd.AddCommand(newCmdInstallCNIPlugin()) - RootCmd.AddCommand(newCmdInstallSP()) RootCmd.AddCommand(newCmdProfile()) RootCmd.AddCommand(newCmdRepair()) RootCmd.AddCommand(newCmdUninject()) From 0ff5c365d671a8911218519859fd5cd9f8061d89 Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Tue, 23 Feb 2021 06:33:34 +0000 Subject: [PATCH 09/11] update TestInstallSp Signed-off-by: Tarun Pothulapati --- test/integration/install_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/install_test.go b/test/integration/install_test.go index b2c92897e6093..ff51befc2111e 100644 --- a/test/integration/install_test.go +++ b/test/integration/install_test.go @@ -880,7 +880,7 @@ func TestUpgradeTestAppWorksAfterUpgrade(t *testing.T) { } func TestInstallSP(t *testing.T) { - cmd := []string{"install-sp"} + cmd := []string{"diagnostics", "install-sp"} out, err := TestHelper.LinkerdRun(cmd...) if err != nil { From 97ec35b636381fa0be2e09102cc296108b7d86d0 Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Wed, 24 Feb 2021 13:48:33 +0000 Subject: [PATCH 10/11] add cp-metrics as a alias for `controller-metrics` Signed-off-by: Tarun Pothulapati --- cli/cmd/controller-metrics.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cli/cmd/controller-metrics.go b/cli/cmd/controller-metrics.go index 44539cbf09a55..60f4db65519a8 100644 --- a/cli/cmd/controller-metrics.go +++ b/cli/cmd/controller-metrics.go @@ -31,8 +31,9 @@ func newCmdControllerMetrics() *cobra.Command { options := newControllerMetricsOptions() cmd := &cobra.Command{ - Use: "controller-metrics", - Short: "Fetch metrics directly from the Linkerd control plane containers", + Use: "controller-metrics", + Aliases: []string{"cp-metrics"}, + Short: "Fetch metrics directly from the Linkerd control plane containers", Long: `Fetch metrics directly from Linkerd control plane containers. This command initiates port-forward to each control plane process, and From c6e2e7db45851317883bf923b477992ffaa334eb Mon Sep 17 00:00:00 2001 From: Tarun Pothulapati Date: Thu, 25 Feb 2021 06:47:52 +0000 Subject: [PATCH 11/11] update cmd suggestions to reflect the new changes Signed-off-by: Tarun Pothulapati --- cli/cmd/diagnostics.go | 2 +- cli/cmd/metrics.go | 6 +++--- test/integration/multicluster/target2/target_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/cmd/diagnostics.go b/cli/cmd/diagnostics.go index 69ab999643400..cfe8aeadc9838 100644 --- a/cli/cmd/diagnostics.go +++ b/cli/cmd/diagnostics.go @@ -20,7 +20,7 @@ func newCmdDiagnostics() *cobra.Command { This command provides subcommands to diagnose the functionality of Linkerd.`, Example: ` # Get control-plane component metrics - linkerd diagnostics cp-metrics + linkerd diagnostics controller-metrics # Get metrics from the web deployment in the emojivoto namespace. linkerd diagnostics proxy-metrics -n emojivoto deploy/web diff --git a/cli/cmd/metrics.go b/cli/cmd/metrics.go index d6e87d7b4fbc6..a69e4de03b886 100644 --- a/cli/cmd/metrics.go +++ b/cli/cmd/metrics.go @@ -62,13 +62,13 @@ func newCmdMetrics() *cobra.Command { * replicationcontrollers * statefulsets`, Example: ` # Get metrics from pod-foo-bar in the default namespace. - linkerd diagnostics metrics po/pod-foo-bar + linkerd diagnostics proxy-metrics po/pod-foo-bar # Get metrics from the web deployment in the emojivoto namespace. - linkerd diagnostics metrics -n emojivoto deploy/web + linkerd diagnostics proxy-metrics -n emojivoto deploy/web # Get metrics from the linkerd-controller pod in the linkerd namespace. - linkerd diagnostics metrics -n linkerd $( + linkerd diagnostics proxy-metrics -n linkerd $( kubectl --namespace linkerd get pod \ --selector linkerd.io/control-plane-component=controller \ --output name diff --git a/test/integration/multicluster/target2/target_test.go b/test/integration/multicluster/target2/target_test.go index f1a8c58487a21..093a966e55860 100644 --- a/test/integration/multicluster/target2/target_test.go +++ b/test/integration/multicluster/target2/target_test.go @@ -26,7 +26,7 @@ func TestMain(m *testing.M) { // successfully issued requests, then we'll see log messages indicating that the // web-svc can't reach the voting-svc (because it's not running). // -// TODO it may be clearer to invoke `linkerd metrics` to check whether we see +// TODO it may be clearer to invoke `linkerd diagnostics proxy-metrics` to check whether we see // connections from the gateway pod to the web-svc? func TestTargetTraffic(t *testing.T) { timeout := time.Minute