fix: merging active controls on host

Need to do the special-case merge before `n.Latest.Merge()`, otherwise
it picks just one set of controls.

Also modified the test to call `Merge()` where the problem happened.
This commit is contained in:
Bryan Boreham
2021-05-21 09:19:08 +00:00
parent fc518cb602
commit 24ffaa5ea9
2 changed files with 14 additions and 13 deletions

View File

@@ -218,6 +218,12 @@ func (n Node) Merge(other Node) Node {
panic("Cannot merge nodes with different topology types: " + topology + " != " + other.Topology)
}
// Special case to merge controls from two different probes.
// Do this first, then the value we want will be picked as newest by n.Latest.Merge().
if topology == Host {
n = n.MergeActiveControls(other)
}
newNode := Node{
ID: id,
Topology: topology,
@@ -229,11 +235,6 @@ func (n Node) Merge(other Node) Node {
Children: n.Children.Merge(other.Children),
}
// Special case to merge controls from two different probes.
if topology == Host {
newNode = newNode.MergeActiveControls(other)
}
return newNode
}