Jelajahi Sumber

Use GetSharedOverheadCostPerMonth for safer access to configured shared overhead

Niko Kovacevic 4 tahun lalu
induk
melakukan
993e37c3b8
1 mengubah file dengan 2 tambahan dan 9 penghapusan
  1. 2 9
      pkg/costmodel/aggregation.go

+ 2 - 9
pkg/costmodel/aggregation.go

@@ -1453,19 +1453,12 @@ func (a *Accesses) ComputeAggregateCostModel(promClient prometheusClient.Client,
 
 	sc := make(map[string]*SharedCostInfo)
 	if !disableSharedOverhead {
-
-		overheadVal := c.SharedOverhead
-
-		cost, err := strconv.ParseFloat(overheadVal, 64)
+		costPerMonth := c.GetSharedOverheadCostPerMonth()
 		durationCoefficient := window.Hours() / timeutil.HoursPerMonth
-		if err != nil {
-			return nil, "", fmt.Errorf("unable to parse shared cost %s: %s", overheadVal, err)
-		}
 		sc["total"] = &SharedCostInfo{
 			Name: "total",
-			Cost: cost * durationCoefficient,
+			Cost: costPerMonth * durationCoefficient,
 		}
-
 	}
 
 	idleCoefficients := make(map[string]float64)