Explorar el Código

add local storage on nodes back to total cluster cost

AjayTripathy hace 6 años
padre
commit
004a79043b
Se han modificado 2 ficheros con 10 adiciones y 1 borrados
  1. 1 0
      costmodel/aggregations.go
  2. 9 1
      costmodel/cluster.go

+ 1 - 0
costmodel/aggregations.go

@@ -117,6 +117,7 @@ func ComputeIdleCoefficient(costData map[string]*CostData, cli prometheusClient.
 		if err != nil || totalClusterCost == 0.0 {
 			return nil, err
 		}
+		klog.Infof("TOTAL CLUSTER COST %f", totalClusterCost)
 		totalClusterCostOverWindow := (totalClusterCost / 730) * windowDuration.Hours()
 		totalContainerCost := 0.0
 		for _, costDatum := range costData {

+ 9 - 1
costmodel/cluster.go

@@ -148,9 +148,17 @@ func ClusterCostsForAllClusters(cli prometheusClient.Client, cloud costAnalyzerC
 		offset = fmt.Sprintf("offset %s", offset)
 	}
 
+	localStorageQuery, err := cloud.GetLocalStorageQuery()
+	if err != nil {
+		return nil, err
+	}
+	if localStorageQuery != "" {
+		localStorageQuery = fmt.Sprintf("+ %s", localStorageQuery)
+	}
+
 	qCores := fmt.Sprintf(queryClusterCores, windowString, offset, windowString, offset, windowString, offset)
 	qRAM := fmt.Sprintf(queryClusterRAM, windowString, offset, windowString, offset)
-	qStorage := fmt.Sprintf(queryStorage, windowString, offset, windowString, offset, "")
+	qStorage := fmt.Sprintf(queryStorage, windowString, offset, windowString, offset, localStorageQuery)
 
 	klog.V(4).Infof("Running query %s", qCores)
 	resultClusterCores, err := Query(cli, qCores)