Просмотр исходного кода

Divide network fields values by pod count

Kaelan Patel 4 лет назад
Родитель
Сommit
7e66b4d05c
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      pkg/costmodel/allocation.go

+ 3 - 3
pkg/costmodel/allocation.go

@@ -1294,7 +1294,7 @@ func applyNetworkTotals(podMap map[podKey]*Pod, resNetworkTransferBytes []*prom.
 
 		for _, pod := range pods {
 			for _, alloc := range pod.Allocations {
-				alloc.NetworkTransferBytes = res.Values[0].Value / float64(len(pod.Allocations))
+				alloc.NetworkTransferBytes = res.Values[0].Value / float64(len(pod.Allocations)) / float64(len(pods))
 			}
 		}
 	}
@@ -1325,7 +1325,7 @@ func applyNetworkTotals(podMap map[podKey]*Pod, resNetworkTransferBytes []*prom.
 
 		for _, pod := range pods {
 			for _, alloc := range pod.Allocations {
-				alloc.NetworkReceiveBytes = res.Values[0].Value / float64(len(pod.Allocations))
+				alloc.NetworkReceiveBytes = res.Values[0].Value / float64(len(pod.Allocations)) / float64(len(pods))
 			}
 		}
 	}
@@ -1372,7 +1372,7 @@ func applyNetworkAllocation(podMap map[podKey]*Pod, resNetworkGiB []*prom.QueryR
 			for _, alloc := range pod.Allocations {
 				gib := res.Values[0].Value / float64(len(pod.Allocations))
 				costPerGiB := costPerGiBByCluster[podKey.Cluster]
-				alloc.NetworkCost = gib * costPerGiB
+				alloc.NetworkCost = gib * costPerGiB / float64(len(pods))
 			}
 		}
 	}