Skip to content

Commit

Permalink
Distinguish between reporting probes and controlling probes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfonso Acosta committed Feb 26, 2016
1 parent 4dc9f78 commit a559a23
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
8 changes: 6 additions & 2 deletions probe/docker/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion probe/docker/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion prog/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 4 additions & 1 deletion render/detailed/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

0 comments on commit a559a23

Please sign in to comment.