mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-19 05:19:35 +00:00
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...
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package host
|
|
|
|
import (
|
|
"github.com/weaveworks/scope/report"
|
|
)
|
|
|
|
// Tagger tags each node in each topology of a report with the origin host
|
|
// node ID of this (probe) host. Effectively, a foreign key linking every node
|
|
// in every topology to an origin host node in the host topology.
|
|
type Tagger struct {
|
|
hostNodeID string
|
|
}
|
|
|
|
// NewTagger tags each node with a foreign key linking it to its origin host
|
|
// in the host topology.
|
|
func NewTagger(hostID string) Tagger {
|
|
return Tagger{
|
|
hostNodeID: report.MakeHostNodeID(hostID),
|
|
}
|
|
}
|
|
|
|
// Name of this tagger, for metrics gathering
|
|
func (Tagger) Name() string { return "Host" }
|
|
|
|
// Tag implements Tagger.
|
|
func (t Tagger) Tag(r report.Report) (report.Report, error) {
|
|
var (
|
|
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.WithParents(parents))
|
|
}
|
|
}
|
|
|
|
for _, topology := range r.Topologies() {
|
|
for _, node := range topology.Nodes {
|
|
topology.AddNode(node.WithSets(sets))
|
|
}
|
|
}
|
|
return r, nil
|
|
}
|