Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinguish between reporting probes and controlling probes #1043

Merged
merged 3 commits into from
Feb 26, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions probe/docker/controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (r *registry) attachContainer(containerID string, req xfer.Request) xfer.Re
hasTTY := c.HasTTY()
id, pipe, err := controls.NewPipe(r.pipes, req.AppID)
if err != nil {
xfer.ResponseError(err)
return xfer.ResponseError(err)
}
local, _ := pipe.Ends()
cw, err := r.client.AttachToContainerNonBlocking(docker_client.AttachToContainerOptions{
Expand Down Expand Up @@ -103,12 +103,12 @@ func (r *registry) execContainer(containerID string, req xfer.Request) xfer.Resp
Container: containerID,
})
if err != nil {
xfer.ResponseError(err)
return xfer.ResponseError(err)
}

id, pipe, err := controls.NewPipe(r.pipes, req.AppID)
if err != nil {
xfer.ResponseError(err)
return xfer.ResponseError(err)
}
local, _ := pipe.Ends()
cw, err := r.client.StartExecNonBlocking(exec.ID, docker_client.StartExecOptions{
Expand Down
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"

This comment was marked as abuse.

)