From 93ab4e96f3c07e99ff32724aafe6887b6eab94ee Mon Sep 17 00:00:00 2001 From: Heng WU Date: Wed, 17 Feb 2021 11:17:06 -0600 Subject: [PATCH] Remove redundant code in kubectl top pod (#99062) * Update top_pod.go * Update top_pod.go --- staging/src/k8s.io/kubectl/pkg/cmd/top/top_pod.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/top/top_pod.go b/staging/src/k8s.io/kubectl/pkg/cmd/top/top_pod.go index 3b9bd1296da..17d1bae4627 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/top/top_pod.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/top/top_pod.go @@ -183,9 +183,9 @@ func (o TopPodOptions) RunTopPod() error { if len(metrics.Items) == 0 { // If the API server query is successful but all the pods are newly created, // the metrics are probably not ready yet, so we return the error here in the first place. - e := verifyEmptyMetrics(o, selector) - if e != nil { - return e + err := verifyEmptyMetrics(o, selector) + if err != nil { + return err } // if we had no errors, be sure we output something. @@ -195,9 +195,6 @@ func (o TopPodOptions) RunTopPod() error { fmt.Fprintf(o.ErrOut, "No resources found in %s namespace.\n", o.Namespace) } } - if err != nil { - return err - } return o.Printer.PrintPodMetrics(metrics.Items, o.PrintContainers, o.AllNamespaces, o.NoHeaders, o.SortBy) }