File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package describe
2
2
3
3
import (
4
4
"fmt"
5
+ "math"
5
6
"os"
6
7
"strings"
7
8
@@ -45,6 +46,10 @@ func describeNodes(nodes []*corepb.Node) {
45
46
// NodeResources describes a list of NodeResource
46
47
// output format can be json or yaml or table
47
48
func NodeResources (resources ... * corepb.NodeResource ) {
49
+ for _ , resource := range resources {
50
+ checkNaNForResource (resource )
51
+ }
52
+
48
53
switch {
49
54
case isJSON ():
50
55
describeAsJSON (resources )
@@ -55,6 +60,21 @@ func NodeResources(resources ...*corepb.NodeResource) {
55
60
}
56
61
}
57
62
63
+ func checkNaNForResource (resource * corepb.NodeResource ) {
64
+ if math .IsNaN (resource .VolumePercent ) {
65
+ resource .VolumePercent = 0
66
+ }
67
+ if math .IsNaN (resource .MemoryPercent ) {
68
+ resource .MemoryPercent = 0
69
+ }
70
+ if math .IsNaN (resource .StoragePercent ) {
71
+ resource .StoragePercent = 0
72
+ }
73
+ if math .IsNaN (resource .CpuPercent ) {
74
+ resource .CpuPercent = 0
75
+ }
76
+ }
77
+
58
78
func describeNodeResources (resources []* corepb.NodeResource ) {
59
79
t := table .NewWriter ()
60
80
t .SetOutputMirror (os .Stdout )
You can’t perform that action at this time.
0 commit comments