Remove redundant code in kubectl top pod (#99062)

* Update top_pod.go

* Update top_pod.go

Kubernetes-commit: 93ab4e96f3c07e99ff32724aafe6887b6eab94ee
This commit is contained in:
Heng WU 2021-02-17 11:17:06 -06:00 committed by Kubernetes Publisher
parent 2b9d0f972e
commit e405ba800f
1 changed files with 3 additions and 6 deletions

View File

@ -183,9 +183,9 @@ func (o TopPodOptions) RunTopPod() error {
if len(metrics.Items) == 0 { if len(metrics.Items) == 0 {
// If the API server query is successful but all the pods are newly created, // 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. // the metrics are probably not ready yet, so we return the error here in the first place.
e := verifyEmptyMetrics(o, selector) err := verifyEmptyMetrics(o, selector)
if e != nil { if err != nil {
return e return err
} }
// if we had no errors, be sure we output something. // 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) 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) return o.Printer.PrintPodMetrics(metrics.Items, o.PrintContainers, o.AllNamespaces, o.NoHeaders, o.SortBy)
} }