mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 17:51:21 +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:
@@ -131,7 +131,7 @@ func (r *Reporter) Report() (report.Report, error) {
|
||||
}
|
||||
|
||||
seenTuples[tuple.key()] = tuple
|
||||
r.addConnection(&rpt, tuple, extraNodeInfo, extraNodeInfo)
|
||||
r.addConnection(&rpt, tuple, extraNodeInfo, extraNodeInfo, report.Sets{}, report.Sets{})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -148,12 +148,14 @@ func (r *Reporter) Report() (report.Report, error) {
|
||||
conn.LocalPort,
|
||||
conn.RemotePort,
|
||||
}
|
||||
toNodeInfo = map[string]string{Procspied: "true"}
|
||||
fromNodeInfo = map[string]string{Procspied: "true"}
|
||||
toNodeInfo = map[string]string{Procspied: "true"}
|
||||
fromNodeInfo = map[string]string{Procspied: "true"}
|
||||
toNodeParents report.Sets
|
||||
fromNodeParents report.Sets
|
||||
)
|
||||
if conn.Proc.PID > 0 {
|
||||
fromNodeInfo[process.PID] = strconv.FormatUint(uint64(conn.Proc.PID), 10)
|
||||
fromNodeInfo[report.HostNodeID] = hostNodeID
|
||||
fromNodeParents.Add(report.Host, report.MakeStringSet(hostNodeID))
|
||||
}
|
||||
|
||||
// If we've already seen this connection, we should know the direction
|
||||
@@ -164,8 +166,9 @@ func (r *Reporter) Report() (report.Report, error) {
|
||||
if (ok && canonical != tuple) || (!ok && tuple.fromPort < tuple.toPort) {
|
||||
tuple.reverse()
|
||||
toNodeInfo, fromNodeInfo = fromNodeInfo, toNodeInfo
|
||||
toNodeParents, fromNodeParents = fromNodeParents, toNodeParents
|
||||
}
|
||||
r.addConnection(&rpt, tuple, fromNodeInfo, toNodeInfo)
|
||||
r.addConnection(&rpt, tuple, fromNodeInfo, toNodeInfo, fromNodeParents, toNodeParents)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +176,7 @@ func (r *Reporter) Report() (report.Report, error) {
|
||||
return rpt, nil
|
||||
}
|
||||
|
||||
func (r *Reporter) addConnection(rpt *report.Report, t fourTuple, extraFromNode, extraToNode map[string]string) {
|
||||
func (r *Reporter) addConnection(rpt *report.Report, t fourTuple, extraFromNode, extraToNode map[string]string, extraFromNodeParents, extraToNodeParents report.Sets) {
|
||||
// Update endpoint topology
|
||||
if !r.includeProcesses {
|
||||
return
|
||||
@@ -201,9 +204,11 @@ func (r *Reporter) addConnection(rpt *report.Report, t fourTuple, extraFromNode,
|
||||
if extraFromNode != nil {
|
||||
fromNode = fromNode.WithLatests(extraFromNode)
|
||||
}
|
||||
fromNode = fromNode.WithParents(extraFromNodeParents)
|
||||
if extraToNode != nil {
|
||||
toNode = toNode.WithLatests(extraToNode)
|
||||
}
|
||||
toNode = toNode.WithParents(extraToNodeParents)
|
||||
rpt.Endpoint = rpt.Endpoint.AddNode(fromNode)
|
||||
rpt.Endpoint = rpt.Endpoint.AddNode(toNode)
|
||||
}
|
||||
|
||||
@@ -25,15 +25,21 @@ func (Tagger) Name() string { return "Host" }
|
||||
// Tag implements Tagger.
|
||||
func (t Tagger) Tag(r report.Report) (report.Report, error) {
|
||||
var (
|
||||
metadata = map[string]string{report.HostNodeID: t.hostNodeID}
|
||||
parents = report.EmptySets.Add(report.Host, report.MakeStringSet(t.hostNodeID))
|
||||
sets = report.EmptySets.Add(report.HostNodeIDs, report.MakeStringSet(t.hostNodeID))
|
||||
parents = report.EmptySets.Add(report.Host, report.MakeStringSet(t.hostNodeID))
|
||||
)
|
||||
|
||||
// Explicitly don't tag Endpoints and Addresses - These topologies include pseudo nodes,
|
||||
// and as such do their own host tagging
|
||||
for _, topology := range []report.Topology{r.Process, r.Container, r.ContainerImage, r.Host, r.Overlay, r.Pod} {
|
||||
for _, node := range topology.Nodes {
|
||||
topology.AddNode(node.WithLatests(metadata).WithParents(parents))
|
||||
topology.AddNode(node.WithParents(parents))
|
||||
}
|
||||
}
|
||||
|
||||
for _, topology := range r.Topologies() {
|
||||
for _, node := range topology.Nodes {
|
||||
topology.AddNode(node.WithSets(sets))
|
||||
}
|
||||
}
|
||||
return r, nil
|
||||
|
||||
Reference in New Issue
Block a user