Przeglądaj źródła

removing logs added to explain the transfer of information and consitency in check between totals and summary allocation

Signed-off-by: Alan Rodrigues <alanr5691@yahoo.com>
Alan Rodrigues 2 lat temu
rodzic
commit
2847e5ab38
2 zmienionych plików z 4 dodań i 27 usunięć
  1. 0 22
      pkg/kubecost/summaryallocation.go
  2. 4 5
      pkg/kubecost/totals.go

+ 0 - 22
pkg/kubecost/summaryallocation.go

@@ -986,34 +986,25 @@ func (sas *SummaryAllocationSet) AggregateBy(aggregateBy []string, options *Allo
 	// 11. Distribute shared resources according to sharing coefficients.
 	// NOTE: ShareEven is not supported
 	if len(shareSet.SummaryAllocations) > 0 {
-		totalTotalCost := 0.0
-		sharedTotalCost := 0.0
 
 		sharingCoeffDenominator := 0.0
 		for _, rt := range allocTotals {
 			sharingCoeffDenominator += rt.TotalCost()
-			totalTotalCost += rt.TotalCost()
 		}
 
 		// Do not include the shared costs, themselves, when determining
 		// sharing coefficients.
 		for _, rt := range sharedResourceTotals {
 			sharingCoeffDenominator -= rt.TotalCost()
-			sharedTotalCost += rt.TotalCost()
 		}
 
 		// Do not include the unmounted costs when determining sharing
 		// coefficients because they do not receive shared costs.
 		sharingCoeffDenominator -= totalUnmountedCost
 
-		log.Infof("BD-152: sharingCoeffDenom=%f (total cost: %f; shared cost: %f; unmounted cost: %f)", sharingCoeffDenominator, totalTotalCost, sharedTotalCost, totalUnmountedCost)
-
 		if sharingCoeffDenominator <= 0.0 {
 			log.Warnf("SummaryAllocation: sharing coefficient denominator is %f", sharingCoeffDenominator)
 		} else {
-			// Needs to be 1.00000
-			sumSharingCoeffs := 0.0
-
 			// Compute sharing coeffs by dividing the thus-far accumulated
 			// numerators by the now-finalized denominator.
 			for key := range sharingCoeffs {
@@ -1022,26 +1013,13 @@ func (sas *SummaryAllocationSet) AggregateBy(aggregateBy []string, options *Allo
 					continue
 				}
 				if sharingCoeffs[key] > 0.0 {
-					before := sharingCoeffs[key]
 					sharingCoeffs[key] /= sharingCoeffDenominator
-
-					log.Infof("BD152: sharingCoeff[%s]=%f ; numerator before=%f", key, sharingCoeffs[key], before)
-
-					sumSharingCoeffs += sharingCoeffs[key]
 				} else {
 					log.Warnf("SummaryAllocation: detected illegal sharing coefficient for %s: %v (setting to zero)", key, sharingCoeffs[key])
 					sharingCoeffs[key] = 0.0
 				}
 			}
 
-			// HERE if you add all the sharingCoeffs, you should get 1.00000 exactly
-			//  "integration": 0.27
-			//  "ally": 0.13
-			//  ...
-			//  TOTAL : 1.000000
-
-			log.Infof("BD152: sum of sharingCoeffs = %f", sumSharingCoeffs)
-
 			for key, sa := range resultSet.SummaryAllocations {
 				// Idle and unmounted allocations, by definition, do not
 				// receive shared cost

+ 4 - 5
pkg/kubecost/totals.go

@@ -119,11 +119,10 @@ func ComputeAllocationTotals(as *AllocationSet, prop string) map[string]*Allocat
 		}
 		if alloc.IsUnmounted() {
 			props := alloc.Properties
-			if props == nil {
-				continue
-			}
-			if props.Container == UnmountedSuffix && props.Namespace == UnmountedSuffix && props.Pod == UnmountedSuffix {
-				continue
+			if props != nil {
+				if props.Container == UnmountedSuffix && props.Namespace == UnmountedSuffix && props.Pod == UnmountedSuffix {
+					continue
+				}
 			}
 		}