mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 09:41:57 +00:00
WIP -- deprecating host node id
It represents which probe the _thing_ was seen from, but in many cases (container images, deployments, replicasets, services), it may have come from several probes. We have previously conflated it to determine which host a thing _lives on_, which it may not even have (deployments, replica sets, services), or it may have multiple (container images). The idea is to separate those two usages. We should convert HostNodeID to a set of HostNodeIDs, and use that to determine which probes have reported the thing. For determining which host a thing lives on we should use the Parents field which we already have, but might need extending to handle Endpoints/etc...
This commit is contained in:
@@ -256,20 +256,18 @@ func MapProcess2Container(n report.Node, _ report.Networks) report.Nodes {
|
||||
// into an per-host "Uncontained" node. If for whatever reason
|
||||
// this node doesn't have a host id in their nodemetadata, it'll
|
||||
// all get grouped into a single uncontained node.
|
||||
var (
|
||||
id string
|
||||
node report.Node
|
||||
)
|
||||
results := report.Nodes{}
|
||||
if containerID, ok := n.Latest.Lookup(docker.ContainerID); ok {
|
||||
id = report.MakeContainerNodeID(containerID)
|
||||
node = NewDerivedNode(id, n).WithTopology(report.Container)
|
||||
id := report.MakeContainerNodeID(containerID)
|
||||
results[id] = NewDerivedNode(id, n).WithTopology(report.Container)
|
||||
} else {
|
||||
id = MakePseudoNodeID(UncontainedID, report.ExtractHostID(n))
|
||||
node = NewDerivedPseudoNode(id, n)
|
||||
node = propagateLatest(report.HostNodeID, n, node)
|
||||
id := MakePseudoNodeID(UncontainedID, report.ExtractHostID(n))
|
||||
node := NewDerivedPseudoNode(id, n)
|
||||
node = propagateParents(report.Host, n, node)
|
||||
node = propagateLatest(IsConnected, n, node)
|
||||
results[id] = node
|
||||
}
|
||||
return report.Nodes{id: node}
|
||||
return results
|
||||
}
|
||||
|
||||
// MapContainer2ContainerImage maps container Nodes to container
|
||||
|
||||
@@ -44,30 +44,27 @@ func MapX2Host(n report.Node, _ report.Networks) report.Nodes {
|
||||
if n.Topology == Pseudo {
|
||||
return report.Nodes{}
|
||||
}
|
||||
hostNodeID, timestamp, ok := n.Latest.LookupEntry(report.HostNodeID)
|
||||
if !ok {
|
||||
return report.Nodes{}
|
||||
ids, _ := n.Parents.Lookup(report.Host)
|
||||
results := report.Nodes{}
|
||||
for _, id := range ids {
|
||||
result := NewDerivedNode(id, n).
|
||||
WithTopology(report.Host).
|
||||
WithSet(report.HostNodeIDs, report.MakeStringSet(id)).
|
||||
WithCounters(map[string]int{n.Topology: 1})
|
||||
result.Children = report.MakeNodeSet(n)
|
||||
results[id] = result
|
||||
}
|
||||
id := report.MakeHostNodeID(report.ExtractHostID(n))
|
||||
result := NewDerivedNode(id, n).WithTopology(report.Host)
|
||||
result.Latest = result.Latest.Set(report.HostNodeID, timestamp, hostNodeID)
|
||||
result.Counters = result.Counters.Add(n.Topology, 1)
|
||||
result.Children = report.MakeNodeSet(n)
|
||||
return report.Nodes{id: result}
|
||||
return results
|
||||
}
|
||||
|
||||
// MapEndpoint2Host takes nodes from the endpoint topology and produces
|
||||
// host nodes or pseudo nodes.
|
||||
func MapEndpoint2Host(n report.Node, local report.Networks) report.Nodes {
|
||||
// Nodes without a hostid are treated as pseudo nodes
|
||||
hostNodeID, timestamp, ok := n.Latest.LookupEntry(report.HostNodeID)
|
||||
// Nodes without a host are treated as pseudo nodes
|
||||
_, ok := n.Parents.Lookup(report.Host)
|
||||
if !ok {
|
||||
return MapEndpoint2Pseudo(n, local)
|
||||
}
|
||||
|
||||
id := report.MakeHostNodeID(report.ExtractHostID(n))
|
||||
result := NewDerivedNode(id, n).WithTopology(report.Host)
|
||||
result.Latest = result.Latest.Set(report.HostNodeID, timestamp, hostNodeID)
|
||||
result.Counters = result.Counters.Add(n.Topology, 1)
|
||||
return report.Nodes{id: result}
|
||||
return MapX2Host(n, local)
|
||||
}
|
||||
|
||||
@@ -112,8 +112,8 @@ func MapEndpoint2Pseudo(n report.Node, local report.Networks) report.Nodes {
|
||||
// It does not have enough info to do that, and the resulting graph
|
||||
// must be merged with a process graph to get that info.
|
||||
func MapEndpoint2Process(n report.Node, local report.Networks) report.Nodes {
|
||||
// Nodes without a hostid are treated as pseudo nodes
|
||||
if _, ok := n.Latest.Lookup(report.HostNodeID); !ok {
|
||||
// Nodes without a host are treated as pseudo nodes
|
||||
if _, ok := n.Parents.Lookup(report.Host); !ok {
|
||||
return MapEndpoint2Pseudo(n, local)
|
||||
}
|
||||
|
||||
|
||||
@@ -159,6 +159,11 @@ func propagateLatest(key string, from, to report.Node) report.Node {
|
||||
return to
|
||||
}
|
||||
|
||||
func propagateParents(topology string, from, to report.Node) report.Node {
|
||||
p, _ := from.Parents.Lookup(topology)
|
||||
return to.WithParents(report.EmptySets.Add(topology, p))
|
||||
}
|
||||
|
||||
// Condition is a predecate over the entire report that can evaluate to true or false.
|
||||
type Condition func(report.Report) bool
|
||||
|
||||
|
||||
Reference in New Issue
Block a user