Skip to content

Commit

Permalink
Dedupe nodes in the ServiceTopology ui endpoint (like done with tags).
Browse files Browse the repository at this point in the history
  • Loading branch information
apollo13 committed Jul 29, 2023
1 parent efa5a6b commit bf3865f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion agent/ui_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,18 @@ func summarizeServices(dump structs.ServiceDump, cfg *config.RuntimeConfig, dc s
sum := getService(psn)

svc := csn.Service
sum.Nodes = append(sum.Nodes, csn.Node.Node)

found := false
for _, existing := range sum.Nodes {
if existing == csn.Node.Node {
found = true
break
}
}
if !found {
sum.Nodes = append(sum.Nodes, csn.Node.Node)
}

sum.Kind = svc.Kind
sum.Datacenter = csn.Node.Datacenter
sum.InstanceCount += 1
Expand Down
2 changes: 1 addition & 1 deletion agent/ui_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2165,7 +2165,7 @@ func TestUIServiceTopology(t *testing.T) {
Name: "cproxy",
Datacenter: "dc1",
Tags: []string{"http", "https"},
Nodes: []string{"cnative", "cnative"},
Nodes: []string{"cnative"},
InstanceCount: 2,
ChecksPassing: 3,
ChecksWarning: 0,
Expand Down

0 comments on commit bf3865f

Please sign in to comment.