Skip to content

Commit

Permalink
Merge pull request #328 from vvhuang-ll/fix/addnodes-skip-empty-ip
Browse files Browse the repository at this point in the history
Fix/addnodes skip empty ip
  • Loading branch information
Lyt99 authored Dec 11, 2024
2 parents 2d9605d + a0ab5b8 commit bc19a8b
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions pkg/controller/graph/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,23 @@ func (g *FlowGraph) AddNodesFromVector(v model.Vector) {
}

func (g *FlowGraph) AddNodesFromSample(v *model.Sample) {
ip := string(v.Metric["src"])
t := string(v.Metric["src_type"])
podName := string(v.Metric["src_pod"])
podNamespace := string(v.Metric["src_namespace"])
nodeName := string(v.Metric["src_node"])
g.AddNode(createNode(t, ip, podNamespace, podName, nodeName))

ip = string(v.Metric["dst"])
t = string(v.Metric["dst_type"])
podName = string(v.Metric["dst_pod"])
podNamespace = string(v.Metric["dst_namespace"])
nodeName = string(v.Metric["dst_node"])
g.AddNode(createNode(t, ip, podNamespace, podName, nodeName))
srcIP := string(v.Metric["src"])
if srcIP != "" {
t := string(v.Metric["src_type"])
podName := string(v.Metric["src_pod"])
podNamespace := string(v.Metric["src_namespace"])
nodeName := string(v.Metric["src_node"])
g.AddNode(createNode(t, srcIP, podNamespace, podName, nodeName))
}

dstIP := string(v.Metric["dst"])
if dstIP != "" {
t := string(v.Metric["dst_type"])
podName := string(v.Metric["dst_pod"])
podNamespace := string(v.Metric["dst_namespace"])
nodeName := string(v.Metric["dst_node"])
g.AddNode(createNode(t, dstIP, podNamespace, podName, nodeName))
}
}

func (g *FlowGraph) AddNode(n Node) {
Expand Down

0 comments on commit bc19a8b

Please sign in to comment.