Skip to content

Commit

Permalink
Merge pull request #238 from coroot/nodes_fix_matching_by_system_uuid
Browse files Browse the repository at this point in the history
nodes: fix matching by `system_uuid` label
  • Loading branch information
apetruhin committed May 29, 2024
2 parents f778362 + d23303e commit aaa8b03
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion constructor/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

func initNodesList(w *model.World, metrics map[string][]model.MetricValues, nodesByID map[model.NodeId]*model.Node) {
nodesBySystemUUID := map[string]*model.Node{}
for _, m := range metrics["node_info"] {
name := m.Labels["hostname"]
id := model.NewNodeIdFromLabels(m.Labels)
Expand All @@ -24,6 +25,7 @@ func initNodesList(w *model.World, metrics map[string][]model.MetricValues, node
node = model.NewNode(id)
w.Nodes = append(w.Nodes, node)
nodesByID[node.Id] = node
nodesBySystemUUID[node.Id.SystemUUID] = node
}
node.Name.Update(m.Values, name)
}
Expand All @@ -34,11 +36,12 @@ func initNodesList(w *model.World, metrics map[string][]model.MetricValues, node
klog.Infoln("invalid `kube_node_info` metric: missing `system_uuid` label")
continue
}
node := nodesByID[id]
node := nodesBySystemUUID[id.SystemUUID]
if node == nil {
node = model.NewNode(id)
w.Nodes = append(w.Nodes, node)
nodesByID[node.Id] = node
nodesBySystemUUID[node.Id.SystemUUID] = node
}
node.K8sName.Update(m.Values, name)
}
Expand Down

0 comments on commit aaa8b03

Please sign in to comment.