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

emit 0 for gpu cost and nonzero for cpu-on-gpu node cost

AjayTripathy 7 лет назад
Родитель
Сommit
365a1ff27c
3 измененных файлов с 7 добавлено и 7 удалено
  1. 5 3
      cloud/gcpprovider.go
  2. 1 1
      costmodel/costmodel.go
  3. 1 3
      main.go

+ 5 - 3
cloud/gcpprovider.go

@@ -276,7 +276,7 @@ func (gcp *GCP) parsePage(r io.Reader, inputKeys map[string]Key) (map[string]*GC
 				for matchnum, group := range provIdRx.FindStringSubmatch(product.Description) {
 					if matchnum == 1 {
 						gpuType = strings.ToLower(strings.Join(strings.Split(group, " "), "-"))
-						klog.V(4).Info("GPU TYPE FOUND: " + gpuType)
+						klog.V(4).Info("GPU type found: " + gpuType)
 					}
 				}
 
@@ -317,7 +317,9 @@ func (gcp *GCP) parsePage(r io.Reader, inputKeys map[string]Key) (map[string]*GC
 							}
 						}
 					} else {
-						if _, ok := inputKeys[candidateKey]; ok {
+						_, ok := inputKeys[candidateKey]
+						_, ok2 := inputKeys[candidateKeyGPU]
+						if ok || ok2 {
 							lastRateIndex := len(product.PricingInfo[0].PricingExpression.TieredRates) - 1
 							var nanos float64
 							if len(product.PricingInfo) > 0 {
@@ -372,7 +374,7 @@ func (gcp *GCP) parsePage(r io.Reader, inputKeys map[string]Key) (map[string]*GC
 									gcpPricingList[candidateKey] = product
 								}
 								if _, ok := gcpPricingList[candidateKeyGPU]; ok {
-									gcpPricingList[candidateKey].Node.VCPUCost = strconv.FormatFloat(hourlyPrice, 'f', -1, 64)
+									gcpPricingList[candidateKeyGPU].Node.VCPUCost = strconv.FormatFloat(hourlyPrice, 'f', -1, 64)
 								} else {
 									product.Node = &Node{
 										VCPUCost: strconv.FormatFloat(hourlyPrice, 'f', -1, 64),

+ 1 - 1
costmodel/costmodel.go

@@ -907,7 +907,7 @@ func ComputeCostDataRange(cli prometheusClient.Client, clientset kubernetes.Inte
 
 				RAMReqV, ok := RAMReqMap[newKey]
 				if !ok {
-					klog.V(2).Info("no RAM requests for " + newKey)
+					klog.V(4).Info("no RAM requests for " + newKey)
 					RAMReqV = []*Vector{}
 				}
 				RAMUsedV, ok := RAMUsedMap[newKey]

+ 1 - 3
main.go

@@ -181,9 +181,7 @@ func (a *Accesses) recordPrices() {
 
 				a.CPUPriceRecorder.WithLabelValues(nodeName, nodeName).Set(cpuCost)
 				a.RAMPriceRecorder.WithLabelValues(nodeName, nodeName).Set(ramCost)
-				if gpu > 0 {
-					a.GPUPriceRecorder.WithLabelValues(nodeName, nodeName).Set(gpuCost)
-				}
+				a.GPUPriceRecorder.WithLabelValues(nodeName, nodeName).Set(gpuCost)
 
 				a.NodeTotalPriceRecorder.WithLabelValues(nodeName, nodeName).Set(totalCost)