Просмотр исходного кода

Deep Copy Labels (#3206) (#3208)

Signed-off-by: Nik Willwerth <nwillwerth@kubecost.com>
nik-kc 11 месяцев назад
Родитель
Сommit
55bbbc097a
1 измененных файлов с 2 добавлено и 1 удалено
  1. 2 1
      pkg/costmodel/costmodel.go

+ 2 - 1
pkg/costmodel/costmodel.go

@@ -3,6 +3,7 @@ package costmodel
 import (
 import (
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
+	"maps"
 	"math"
 	"math"
 	"regexp"
 	"regexp"
 	"strconv"
 	"strconv"
@@ -386,7 +387,7 @@ func (cm *CostModel) ComputeCostData(cli prometheusClient.Client, cp costAnalyze
 			ns := pod.Namespace
 			ns := pod.Namespace
 
 
 			nsLabels := namespaceLabelsMapping[ns+","+clusterID]
 			nsLabels := namespaceLabelsMapping[ns+","+clusterID]
-			podLabels := pod.Labels
+			podLabels := maps.Clone(pod.Labels)
 			if podLabels == nil {
 			if podLabels == nil {
 				podLabels = make(map[string]string)
 				podLabels = make(map[string]string)
 			}
 			}