mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-02 17:50:39 +00:00
Distinguish between reporting probes and controlling probes
This commit is contained in:
@@ -20,14 +20,16 @@ const (
|
||||
type Reporter struct {
|
||||
registry Registry
|
||||
hostID string
|
||||
probeID string
|
||||
probe *probe.Probe
|
||||
}
|
||||
|
||||
// NewReporter makes a new Reporter
|
||||
func NewReporter(registry Registry, hostID string, probe *probe.Probe) *Reporter {
|
||||
func NewReporter(registry Registry, hostID string, probeID string, probe *probe.Probe) *Reporter {
|
||||
reporter := &Reporter{
|
||||
registry: registry,
|
||||
hostID: hostID,
|
||||
probeID: probeID,
|
||||
probe: probe,
|
||||
}
|
||||
registry.WatchContainerUpdates(reporter.ContainerUpdated)
|
||||
@@ -103,9 +105,11 @@ func (r *Reporter) containerTopology(localAddrs []net.IP) report.Topology {
|
||||
Icon: "fa-terminal",
|
||||
})
|
||||
|
||||
metadata := map[string]string{report.ControlProbeID: r.probeID}
|
||||
|
||||
r.registry.WalkContainers(func(c Container) {
|
||||
nodeID := report.MakeContainerNodeID(c.ID())
|
||||
result.AddNode(nodeID, c.GetNode(r.hostID, localAddrs))
|
||||
result.AddNode(nodeID, c.GetNode(r.hostID, localAddrs).WithLatests(metadata))
|
||||
})
|
||||
|
||||
return result
|
||||
|
||||
@@ -51,7 +51,7 @@ var (
|
||||
|
||||
func TestReporter(t *testing.T) {
|
||||
containerImageNodeID := report.MakeContainerImageNodeID("baz")
|
||||
rpt, err := docker.NewReporter(mockRegistryInstance, "host1", nil).Report()
|
||||
rpt, err := docker.NewReporter(mockRegistryInstance, "host1", "probeID", nil).Report()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ func probeMain() {
|
||||
if registry, err := docker.NewRegistry(*dockerInterval, clients); err == nil {
|
||||
defer registry.Stop()
|
||||
p.AddTagger(docker.NewTagger(registry, processCache))
|
||||
p.AddReporter(docker.NewReporter(registry, hostID, p))
|
||||
p.AddReporter(docker.NewReporter(registry, hostID, probeID, p))
|
||||
} else {
|
||||
log.Errorf("Docker: failed to start registry: %v", err)
|
||||
}
|
||||
|
||||
@@ -101,7 +101,10 @@ func controlsFor(topology report.Topology, nodeID string) []ControlInstance {
|
||||
|
||||
for _, id := range node.Controls.Controls {
|
||||
if control, ok := topology.Controls[id]; ok {
|
||||
probeID, _ := node.Latest.Lookup(report.ProbeID)
|
||||
probeID, ok := node.Latest.Lookup(report.ControlProbeID)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
result = append(result, ControlInstance{
|
||||
ProbeID: probeID,
|
||||
NodeID: nodeID,
|
||||
|
||||
@@ -209,4 +209,6 @@ const (
|
||||
HostNodeID = "host_node_id"
|
||||
// ProbeID is the random ID of the probe which generated the specific node.
|
||||
ProbeID = "probe_id"
|
||||
// ControlProbeID is the random ID of the probe which controls the specific node.
|
||||
ControlProbeID = "control_probe_id"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user