mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 22:20:18 +00:00
print nodes for those metrics is somehow unreachable
This commit is contained in:
@@ -76,6 +76,12 @@ func (printer *TopCmdPrinter) PrintNodeMetrics(metrics []metricsapi.NodeMetrics,
|
|||||||
Metrics: usage,
|
Metrics: usage,
|
||||||
Available: availableResources[m.Name],
|
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
|
return nil
|
||||||
}
|
}
|
||||||
@@ -171,6 +177,14 @@ func printMetricsLine(out io.Writer, metrics *ResourceMetricsInfo) {
|
|||||||
fmt.Fprint(out, "\n")
|
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{}) {
|
func printValue(out io.Writer, value interface{}) {
|
||||||
fmt.Fprintf(out, "%v\t", value)
|
fmt.Fprintf(out, "%v\t", value)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user