Преглед изворни кода

Add NodeLabels one by one, instead of assigning the map of labels (#2534) (#2551)

directly to the result. This protects against the case where there exist
multiple `kube_node_labels` metrics for a single node.

Signed-off-by: thomasvn <thomasnguyen96@gmail.com>
Signed-off-by: Michael Dresser <michaelmdresser@gmail.com>
Co-authored-by: Thomas Nguyen <thomasvn.dev@gmail.com>
Michael Dresser пре 2 година
родитељ
комит
d1fa872dbc
1 измењених фајлова са 6 додато и 1 уклоњено
  1. 6 1
      pkg/costmodel/cluster_helpers.go

+ 6 - 1
pkg/costmodel/cluster_helpers.go

@@ -640,7 +640,12 @@ func buildLabelsMap(
 		// ingested label data. This removes the label_ prefix that prometheus
 		// adds to emitted labels. It also keeps from ingesting prometheus labels
 		// that aren't a part of the asset.
-		m[key] = result.GetLabels()
+		if _, ok := m[key]; !ok {
+			m[key] = map[string]string{}
+		}
+		for k, l := range result.GetLabels() {
+			m[key][k] = l
+		}
 	}
 	return m
 }