Distinguish between reporting probes and controlling probes

This commit is contained in:
Alfonso Acosta
2016-02-26 01:46:18 +00:00
parent 4dc9f7834e
commit a559a23dba
5 changed files with 14 additions and 5 deletions

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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)
}

View File

@@ -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,

View File

@@ -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"
)