Skip to content

Commit

Permalink
Fix bug in both Allocation and Summary Allocation where shared tenanc…
Browse files Browse the repository at this point in the history
…y cost would slightly skew sharing coefficients for shared resources.
  • Loading branch information
nikovacevic committed Mar 17, 2022
1 parent fd079e1 commit 7ce8347
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/kubecost/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -1499,8 +1499,8 @@ func computeShareCoeffs(aggregateBy []string, options *AllocationAggregationOpti
} else {
// Both are additive for weighted distribution, where each
// cumulative coefficient will be divided by the total.
coeffs[name] += alloc.TotalCost()
total += alloc.TotalCost()
coeffs[name] += alloc.TotalCost() - alloc.SharedCost
total += alloc.TotalCost() - alloc.SharedCost
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/kubecost/summaryallocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ func (sas *SummaryAllocationSet) AggregateBy(aggregateBy []string, options *Allo
// NOTE: SummaryAllocation does not support ShareEven, so only record
// by cost for cost-weighted distribution.
if sharingCoeffs != nil {
sharingCoeffs[key] += sa.TotalCost()
sharingCoeffs[key] += sa.TotalCost() - sa.SharedCost
}

// 6. Distribute idle allocations according to the idle coefficients.
Expand Down

0 comments on commit 7ce8347

Please sign in to comment.