Procházet zdrojové kódy

Merge pull request #604 from kubecost/AjayTripathy-fix-nan

nan shield on total of 0
Ajay Tripathy před 5 roky
rodič
revize
3d8da4a2f8
1 změnil soubory, kde provedl 4 přidání a 1 odebrání
  1. 4 1
      pkg/costmodel/cluster.go

+ 4 - 1
pkg/costmodel/cluster.go

@@ -679,7 +679,10 @@ func ClusterNodes(cp cloud.Provider, client prometheus.Client, duration, offset
 		if modeTotals, ok := clusterNodeModeCPUTotal[key]; ok {
 			for mode, subtotal := range modeTotals {
 				// Compute percentage for the current cluster, node, mode
-				pct := subtotal / total
+				pct := 0.0
+				if total > 0 {
+					pct = subtotal / total
+				}
 
 				if _, ok := nodeMap[key]; !ok {
 					log.Warningf("ClusterNodes: CPU mode data for unidentified node")