Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
Signed-off-by: tanujd11 <dwiveditanuj41@gmail.com>
  • Loading branch information
tanujd11 committed Sep 20, 2023
1 parent 145196b commit 2a6c57c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
6 changes: 3 additions & 3 deletions internal/cmd/egctl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func retrieveConfigDump(args []string, includeEds bool, configType envoyConfigTy
for _, pod := range pods {
pod := pod
go func() {
fw, err := portForwarder(cli, pod, adminPort)
fw, err := portForwarder(cli, pod)
if err != nil {
errs = multierror.Append(errs, err)
return
Expand Down Expand Up @@ -180,8 +180,8 @@ func fetchRunningEnvoyPods(c kube.CLIClient, nn types.NamespacedName, labelSelec
}

// portForwarder returns a port forwarder instance for a single Pod.
func portForwarder(cli kube.CLIClient, nn types.NamespacedName, port int) (kube.PortForwarder, error) {
fw, err := kube.NewLocalPortForwarder(cli, nn, 0, port)
func portForwarder(cli kube.CLIClient, nn types.NamespacedName) (kube.PortForwarder, error) {
fw, err := kube.NewLocalPortForwarder(cli, nn, 0, adminPort)
if err != nil {
return nil, err
}
Expand Down
16 changes: 7 additions & 9 deletions internal/cmd/egctl/envoy_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ func newEnvoyStatsConfigCmd() *cobra.Command {
var podName, podNamespace string

statsConfigCmd := &cobra.Command{
Use: "envoy-stats [<type>/]<name>[.<namespace>]",
Use: "stats [<type>/]<name>[.<namespace>]",
Short: "Retrieves Envoy metrics in the specified pod",
Long: `Retrieve Envoy emitted metrics for the specified pod.`,
Example: ` # Retrieve Envoy emitted metrics for the specified pod.
egctl experimental envoy-stats <pod-name[.namespace]>
egctl experimental stats <pod-name[.namespace]>
# Retrieve Envoy server metrics in prometheus format
egctl experimental envoy-stats <pod-name[.namespace]> --output prom
egctl experimental stats <pod-name[.namespace]> --output prom
# Retrieve Envoy server metrics in prometheus format with merged application metrics
egctl experimental envoy-stats <pod-name[.namespace]> --output prom-merged
egctl experimental stats <pod-name[.namespace]> --output prom-merged
# Retrieve Envoy cluster metrics
egctl experimental envoy-stats <pod-name[.namespace]> --type clusters
egctl experimental stats <pod-name[.namespace]> --type clusters
`,
Aliases: []string{"es"},
Args: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -132,15 +132,14 @@ func newEnvoyStatsConfigCmd() *cobra.Command {

func setupEnvoyServerStatsConfig(kubeClient kubernetes.CLIClient, podName, podNamespace string, outputFormat string) (string, error) {
path := "stats"
port := 19000
if outputFormat == jsonOutput || outputFormat == yamlOutput {
// for yaml output we will convert the json to yaml when printed
path += "?format=json"
} else {
path += "/prometheus"
}

Check warning on line 140 in internal/cmd/egctl/envoy_stats.go

View check run for this annotation

Codecov / codecov/patch

internal/cmd/egctl/envoy_stats.go#L133-L140

Added lines #L133 - L140 were not covered by tests

fw, err := portForwarder(kubeClient, types.NamespacedName{Namespace: podNamespace, Name: podName}, port)
fw, err := portForwarder(kubeClient, types.NamespacedName{Namespace: podNamespace, Name: podName})
if err != nil {
return "", fmt.Errorf("failed to initialize pod-forwarding for %s/%s: %v", podNamespace, podName, err)
}
Expand All @@ -159,12 +158,11 @@ func setupEnvoyServerStatsConfig(kubeClient kubernetes.CLIClient, podName, podNa

func setupEnvoyClusterStatsConfig(kubeClient kubernetes.CLIClient, podName, podNamespace string, outputFormat string) (string, error) {
path := "clusters"
port := 19000
if outputFormat == jsonOutput || outputFormat == yamlOutput {
// for yaml output we will convert the json to yaml when printed
path += "?format=json"
}
fw, err := portForwarder(kubeClient, types.NamespacedName{Namespace: podNamespace, Name: podName}, port)
fw, err := portForwarder(kubeClient, types.NamespacedName{Namespace: podNamespace, Name: podName})
if err != nil {
return "", fmt.Errorf("failed to initialize pod-forwarding for %s/%s: %v", podNamespace, podName, err)
}
Expand Down

0 comments on commit 2a6c57c

Please sign in to comment.