Procházet zdrojové kódy

Merge pull request #489 from kubecost/AjayTripathy-fix-noderemoval

add node removal logs and correctly remove nodes
Ajay Tripathy před 5 roky
rodič
revize
1bbaaf49ec
1 změnil soubory, kde provedl 26 přidání a 5 odebrání
  1. 26 5
      pkg/costmodel/router.go

+ 26 - 5
pkg/costmodel/router.go

@@ -744,7 +744,7 @@ func (a *Accesses) recordPrices() {
 				a.RAMPriceRecorder.WithLabelValues(nodeName, nodeName, nodeType, nodeRegion).Set(ramCost)
 				a.GPUPriceRecorder.WithLabelValues(nodeName, nodeName, nodeType, nodeRegion).Set(gpuCost)
 				a.NodeTotalPriceRecorder.WithLabelValues(nodeName, nodeName, nodeType, nodeRegion).Set(totalCost)
-				labelKey := getKeyFromLabelStrings(nodeName, nodeName)
+				labelKey := getKeyFromLabelStrings(nodeName, nodeName, nodeType, nodeRegion)
 				nodeSeen[labelKey] = true
 			}
 
@@ -819,11 +819,32 @@ func (a *Accesses) recordPrices() {
 			}
 			for labelString, seen := range nodeSeen {
 				if !seen {
+					klog.Infof("Removing %s from nodes", labelString)
 					labels := getLabelStringsFromKey(labelString)
-					a.NodeTotalPriceRecorder.DeleteLabelValues(labels...)
-					a.CPUPriceRecorder.DeleteLabelValues(labels...)
-					a.GPUPriceRecorder.DeleteLabelValues(labels...)
-					a.RAMPriceRecorder.DeleteLabelValues(labels...)
+					ok := a.NodeTotalPriceRecorder.DeleteLabelValues(labels...)
+					if ok {
+						klog.Infof("removed %s from totalprice", labelString)
+					} else {
+						klog.Infof("FAILURE TO REMOVE %s from totalprice", labelString)
+					}
+					ok = a.CPUPriceRecorder.DeleteLabelValues(labels...)
+					if ok {
+						klog.Infof("removed %s from cpuprice", labelString)
+					} else {
+						klog.Infof("FAILURE TO REMOVE %s from cpuprice", labelString)
+					}
+					ok = a.GPUPriceRecorder.DeleteLabelValues(labels...)
+					if ok {
+						klog.Infof("removed %s from gpuprice", labelString)
+					} else {
+						klog.Infof("FAILURE TO REMOVE %s from gpuprice", labelString)
+					}
+					ok = a.RAMPriceRecorder.DeleteLabelValues(labels...)
+					if ok {
+						klog.Infof("removed %s from ramprice", labelString)
+					} else {
+						klog.Infof("FAILURE TO REMOVE %s from ramprice", labelString)
+					}
 					delete(nodeSeen, labelString)
 				}
 				nodeSeen[labelString] = false