瀏覽代碼

Prevent error on missing idleKey

Sean Holcomb 5 年之前
父節點
當前提交
00a01c4747
共有 1 個文件被更改,包括 6 次插入5 次删除
  1. 6 5
      pkg/kubecost/allocation.go

+ 6 - 5
pkg/kubecost/allocation.go

@@ -930,8 +930,8 @@ func (as *AllocationSet) AggregateBy(aggregateBy []string, options *AllocationAg
 	for _, alloc := range as.allocations {
 	for _, alloc := range as.allocations {
 		idleKey, err := alloc.getIdleKey(options)
 		idleKey, err := alloc.getIdleKey(options)
 		if err != nil {
 		if err != nil {
-			log.Warningf("AllocationSet.AggregateBy: missing idleKey for allocation: %s", alloc.Name)
-			return err
+			log.DedupedInfof(5,"AllocationSet.AggregateBy: missing idleKey for allocation: %s", alloc.Name)
+			continue
 		}
 		}
 
 
 		skip := false
 		skip := false
@@ -1018,8 +1018,8 @@ func (as *AllocationSet) AggregateBy(aggregateBy []string, options *AllocationAg
 		for _, alloc := range shareSet.allocations {
 		for _, alloc := range shareSet.allocations {
 			idleKey, err := alloc.getIdleKey(options)
 			idleKey, err := alloc.getIdleKey(options)
 			if err != nil {
 			if err != nil {
-				log.Warningf("AllocationSet.AggregateBy: missing idleKey for allocation: %s", alloc.Name)
-				return err
+				log.DedupedWarningf(5, "AllocationSet.AggregateBy: missing idleKey for allocation: %s", alloc.Name)
+				continue
 			}
 			}
 
 
 			// Distribute idle allocations by coefficient per-idleKey, per-allocation
 			// Distribute idle allocations by coefficient per-idleKey, per-allocation
@@ -1240,7 +1240,8 @@ func computeIdleCoeffs(options *AllocationAggregationOptions, as *AllocationSet,
 
 
 		idleKey, err := alloc.getIdleKey(options)
 		idleKey, err := alloc.getIdleKey(options)
 		if err != nil {
 		if err != nil {
-			return nil, err
+			// skip allocations that are missing idleKey
+			continue
 		}
 		}
 
 
 		// get the name key for the allocation
 		// get the name key for the allocation