From dc2184f69f7d542c91c443128f676e61462719e9 Mon Sep 17 00:00:00 2001 From: yue9944882 <291271447@qq.com> Date: Mon, 28 May 2018 17:12:37 +0800 Subject: [PATCH] print nodes for those metrics is somehow unreachable --- pkg/kubectl/metricsutil/metrics_printer.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/kubectl/metricsutil/metrics_printer.go b/pkg/kubectl/metricsutil/metrics_printer.go index ff92b055f0..1eb754c5d1 100644 --- a/pkg/kubectl/metricsutil/metrics_printer.go +++ b/pkg/kubectl/metricsutil/metrics_printer.go @@ -76,6 +76,12 @@ func (printer *TopCmdPrinter) PrintNodeMetrics(metrics []metricsapi.NodeMetrics, Metrics: usage, Available: availableResources[m.Name], }) + delete(availableResources, m.Name) + } + + // print lines for nodes of which the metrics is unreachable. + for nodeName := range availableResources { + printMissingMetricsNodeLine(w, nodeName) } return nil } @@ -171,6 +177,14 @@ func printMetricsLine(out io.Writer, metrics *ResourceMetricsInfo) { fmt.Fprint(out, "\n") } +func printMissingMetricsNodeLine(out io.Writer, nodeName string) { + printValue(out, nodeName) + for i := 0; i < len(MeasuredResources); i++ { + printValue(out, "-\t-\t") + } + fmt.Fprint(out, "\n") +} + func printValue(out io.Writer, value interface{}) { fmt.Fprintf(out, "%v\t", value) }