Ver código fonte

code review fixes

Signed-off-by: Alex Meijer <ameijer@kubecost.com>
Alex Meijer 3 anos atrás
pai
commit
78490242d4
2 arquivos alterados com 18 adições e 17 exclusões
  1. 2 1
      pkg/costmodel/aggregation.go
  2. 16 16
      pkg/kubecost/allocation.go

+ 2 - 1
pkg/costmodel/aggregation.go

@@ -2282,7 +2282,8 @@ func (a *Accesses) ComputeAllocationHandler(w http.ResponseWriter, r *http.Reque
 	if accumulateBy != kubecost.AccumulateOptionNone {
 		asr, err = asr.Accumulate(accumulateBy)
 		if err != nil {
-			WriteError(w, InternalServerError(err.Error()))
+			log.Errorf("error accumulating by %v: %s", accumulateBy, err)
+			WriteError(w, InternalServerError(fmt.Errorf("error accumulating by %v: %s", accumulateBy, err).Error()))
 			return
 		}
 	}

+ 16 - 16
pkg/kubecost/allocation.go

@@ -1917,26 +1917,26 @@ func deriveProportionalAssetResourceCostsFromIdleCoefficients(idleCoeffs map[str
 		GPUPercentage:              gpuPct,
 		RAMPercentage:              ramPct,
 		NodeResourceCostPercentage: nodeResourceCostPercentage,
-	}
-
-	parc.CPUComponents = []ParcsComponent{
-		{
-			TotalCost:       totals[idleId]["cpu"],
-			UsageProportion: idleCoeffs[idleId][allocation.Name]["cpu"],
+		CPUComponents: []ParcsComponent{
+			{
+				TotalCost:       totals[idleId]["cpu"],
+				UsageProportion: idleCoeffs[idleId][allocation.Name]["cpu"],
+			},
 		},
-	}
-	parc.GPUComponents = []ParcsComponent{
-		{
-			TotalCost:       totals[idleId]["gpu"],
-			UsageProportion: idleCoeffs[idleId][allocation.Name]["gpu"],
+		GPUComponents: []ParcsComponent{
+			{
+				TotalCost:       totals[idleId]["gpu"],
+				UsageProportion: idleCoeffs[idleId][allocation.Name]["gpu"],
+			},
 		},
-	}
-	parc.RAMComponents = []ParcsComponent{
-		{
-			TotalCost:       totals[idleId]["ram"],
-			UsageProportion: idleCoeffs[idleId][allocation.Name]["ram"],
+		RAMComponents: []ParcsComponent{
+			{
+				TotalCost:       totals[idleId]["ram"],
+				UsageProportion: idleCoeffs[idleId][allocation.Name]["ram"],
+			},
 		},
 	}
+
 	return parc, nil
 }