Forráskód Böngészése

fix idle resolutions

AjayTripathy 6 éve
szülő
commit
38c0decb7d
2 módosított fájl, 6 hozzáadás és 3 törlés
  1. 3 0
      costmodel/aggregations.go
  2. 3 3
      costmodel/router.go

+ 3 - 0
costmodel/aggregations.go

@@ -118,6 +118,9 @@ func ComputeIdleCoefficient(costData map[string]*CostData, cli prometheusClient.
 
 	resolutionDuration, err := ParseDuration(resolution)
 	resolutionCoefficient := resolutionDuration.Hours()
+	if resolutionCoefficient < 1 {
+		resolutionCoefficient = 1 // just use 1 hour here, for numbers less than 1.
+	}
 
 	allTotals, err := ClusterCostsForAllClusters(cli, cp, windowString, offset)
 	if err != nil {

+ 3 - 3
costmodel/router.go

@@ -492,9 +492,7 @@ func (a *Accesses) AggregateCostModel(w http.ResponseWriter, r *http.Request, ps
 
 	// determine resolution by size of duration
 	resolution := duration
-	if durationHours > 1 {
-		resolution = "1h"
-	} else if durationHours >= 2160 {
+	if durationHours >= 2160 {
 		// 90 days
 		resolution = "72h"
 	} else if durationHours >= 720 {
@@ -506,6 +504,8 @@ func (a *Accesses) AggregateCostModel(w http.ResponseWriter, r *http.Request, ps
 	} else if durationHours >= 48 {
 		// 2 days
 		resolution = "2h"
+	} else if durationHours > 1 {
+		resolution = "1h"
 	}
 	resolutionDuration, err := ParseDuration(resolution)
 	resolutionHours := resolutionDuration.Hours()