Kaynağa Gözat

Set providerID on custom pricing

Signed-off-by: Sean Holcomb <seanholcomb@gmail.com>
Sean Holcomb 3 yıl önce
ebeveyn
işleme
7efd4008f7
1 değiştirilmiş dosya ile 7 ekleme ve 4 silme
  1. 7 4
      pkg/costmodel/allocation_helpers.go

+ 7 - 4
pkg/costmodel/allocation_helpers.go

@@ -1588,7 +1588,7 @@ func (cm *CostModel) applyNodesToPod(podMap map[podKey]*pod, nodeMap map[nodeKey
 
 // getCustomNodePricing converts the CostModel's configured custom pricing
 // values into a nodePricing instance.
-func (cm *CostModel) getCustomNodePricing(spot bool) *nodePricing {
+func (cm *CostModel) getCustomNodePricing(spot bool, providerID string) *nodePricing {
 	customPricingConfig, err := cm.Provider.GetConfig()
 	if err != nil {
 		return nil
@@ -1603,7 +1603,10 @@ func (cm *CostModel) getCustomNodePricing(spot bool) *nodePricing {
 		ramCostStr = customPricingConfig.SpotRAM
 	}
 
-	node := &nodePricing{Source: "custom"}
+	node := &nodePricing{
+		Source:     "custom",
+		ProviderID: providerID,
+	}
 
 	costPerCPUHr, err := strconv.ParseFloat(cpuCostStr, 64)
 	if err != nil {
@@ -1639,7 +1642,7 @@ func (cm *CostModel) getNodePricing(nodeMap map[nodeKey]*nodePricing, nodeKey no
 		if nodeKey.Node != "" {
 			log.DedupedWarningf(5, "CostModel: failed to find node for %s", nodeKey)
 		}
-		return cm.getCustomNodePricing(false)
+		return cm.getCustomNodePricing(false, "")
 	}
 
 	// If custom pricing is enabled and can be retrieved, override detected
@@ -1649,7 +1652,7 @@ func (cm *CostModel) getNodePricing(nodeMap map[nodeKey]*nodePricing, nodeKey no
 		log.Warnf("CostModel: failed to load custom pricing: %s", err)
 	}
 	if cloud.CustomPricesEnabled(cm.Provider) && customPricingConfig != nil {
-		return cm.getCustomNodePricing(node.Preemptible)
+		return cm.getCustomNodePricing(node.Preemptible, node.ProviderID)
 	}
 
 	node.Source = "prometheus"