瀏覽代碼

offset fixes for idle

AjayTripathy 6 年之前
父節點
當前提交
c7357820a3
共有 2 個文件被更改,包括 4 次插入3 次删除
  1. 3 1
      costmodel/cluster.go
  2. 1 2
      costmodel/router.go

+ 3 - 1
costmodel/cluster.go

@@ -144,7 +144,9 @@ func resultToTotal(qr interface{}) (map[string][][]string, error) {
 // ClusterCostsForAllClusters gives the cluster costs averaged over a window of time for all clusters.
 func ClusterCostsForAllClusters(cli prometheusClient.Client, cloud costAnalyzerCloud.Provider, windowString, offset string) (map[string]*Totals, error) {
 
-	offset = fmt.Sprintf("offset 3h") // Set offset to 3h for block sync
+	if offset != "" {
+		offset = fmt.Sprintf("offset %s", offset)
+	}
 
 	qCores := fmt.Sprintf(queryClusterCores, offset, offset, offset)
 	qRAM := fmt.Sprintf(queryClusterRAM, offset, offset)

+ 1 - 2
costmodel/router.go

@@ -401,7 +401,6 @@ func (a *Accesses) AggregateCostModel(w http.ResponseWriter, r *http.Request, ps
 	if remoteAvailable == "true" && remote != "false" {
 		remoteEnabled = true
 	}
-	klog.Infof("REMOTE ENABLED: %t", remoteEnabled)
 
 	// Use Thanos Client if it exists (enabled) and remote flag set
 	var pClient prometheusClient.Client
@@ -433,7 +432,7 @@ func (a *Accesses) AggregateCostModel(w http.ResponseWriter, r *http.Request, ps
 	idleCoefficients := make(map[string]float64)
 	if allocateIdle {
 		windowStr := fmt.Sprintf("%dh", int(dur.Hours()))
-		if a.ThanosClient != nil {
+		if a.ThanosClient != nil && remoteEnabled {
 			offset = "3h"
 		}
 		idleCoefficients, err = ComputeIdleCoefficient(data, pClient, a.Cloud, discount, windowStr, offset)