Niko Kovacevic 5 лет назад
Родитель
Сommit
7412502e07
2 измененных файлов с 9 добавлено и 6 удалено
  1. 6 6
      pkg/costmodel/allocation.go
  2. 3 0
      pkg/kubecost/allocation.go

+ 6 - 6
pkg/costmodel/allocation.go

@@ -354,7 +354,7 @@ func (cm *CostModel) ComputeAllocation(start, end time.Time) (*kubecost.Allocati
 		nodeKey := newNodeKey(cluster, node)
 		nodeKey := newNodeKey(cluster, node)
 
 
 		if n, ok := nodeMap[nodeKey]; !ok {
 		if n, ok := nodeMap[nodeKey]; !ok {
-			if pod != "unmounted-pvs" {
+			if pod != kubecost.UnmountedSuffix {
 				log.Warningf("CostModel.ComputeAllocation: failed to find node %s for %s", nodeKey, alloc.Name)
 				log.Warningf("CostModel.ComputeAllocation: failed to find node %s for %s", nodeKey, alloc.Name)
 			}
 			}
 		} else {
 		} else {
@@ -1369,9 +1369,9 @@ func applyUnmountedPVs(window kubecost.Window, allocationMap map[containerKey]*k
 	}
 	}
 
 
 	for cluster, amount := range unmountedPVCost {
 	for cluster, amount := range unmountedPVCost {
-		container := "unmounted-pvs"
-		pod := "unmounted-pvs"
-		namespace := ""
+		container := kubecost.UnmountedSuffix
+		pod := kubecost.UnmountedSuffix
+		namespace := kubecost.UnmountedSuffix
 		node := ""
 		node := ""
 
 
 		containerKey := newContainerKey(cluster, namespace, pod, container)
 		containerKey := newContainerKey(cluster, namespace, pod, container)
@@ -1411,8 +1411,8 @@ func applyUnmountedPVCs(window kubecost.Window, allocationMap map[containerKey]*
 	}
 	}
 
 
 	for key, amount := range unmountedPVCCost {
 	for key, amount := range unmountedPVCCost {
-		container := "unmounted-pvs"
-		pod := "unmounted-pvs"
+		container := kubecost.UnmountedSuffix
+		pod := kubecost.UnmountedSuffix
 		namespace := key.Namespace
 		namespace := key.Namespace
 		node := ""
 		node := ""
 		cluster := key.Cluster
 		cluster := key.Cluster

+ 3 - 0
pkg/kubecost/allocation.go

@@ -29,6 +29,9 @@ const SharedSuffix = "__shared__"
 // UnallocatedSuffix indicates an unallocated allocation property
 // UnallocatedSuffix indicates an unallocated allocation property
 const UnallocatedSuffix = "__unallocated__"
 const UnallocatedSuffix = "__unallocated__"
 
 
+// UnmountedSuffix indicated allocation to an unmounted PV
+const UnmountedSuffix = "__unmounted__"
+
 // ShareWeighted indicates that a shared resource should be shared as a
 // ShareWeighted indicates that a shared resource should be shared as a
 // proportion of the cost of the remaining allocations.
 // proportion of the cost of the remaining allocations.
 const ShareWeighted = "__weighted__"
 const ShareWeighted = "__weighted__"