From 23be0d9aa9a37397276795850c4d17c46fcac6fe Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Fri, 13 Nov 2015 11:16:09 +0000 Subject: [PATCH] Don't tag processes with stopped container ids. --- probe/docker/container.go | 19 +++++++++++-------- probe/docker/tagger.go | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/probe/docker/container.go b/probe/docker/container.go index 56bdfc01b..19b8d4807 100644 --- a/probe/docker/container.go +++ b/probe/docker/container.go @@ -84,6 +84,7 @@ type Container interface { PID() int Hostname() string GetNode(string, []net.IP) report.Node + State() string StartGatheringStats() error StopGatheringStats() @@ -131,6 +132,15 @@ func (c *container) Hostname() string { c.container.Config.Domainname) } +func (c *container) State() string { + if c.container.State.Paused { + return StatePaused + } else if c.container.State.Running { + return StateRunning + } + return StateStopped +} + func (c *container) StartGatheringStats() error { c.Lock() defer c.Unlock() @@ -297,14 +307,7 @@ func (c *container) GetNode(hostID string, localAddrs []net.IP) report.Node { ipsWithScopes = append(ipsWithScopes, report.MakeScopedAddressNodeID(hostID, ip)) } - var state string - if c.container.State.Paused { - state = StatePaused - } else if c.container.State.Running { - state = StateRunning - } else { - state = StateStopped - } + state := c.State() result := report.MakeNodeWith(map[string]string{ ContainerID: c.ID(), diff --git a/probe/docker/tagger.go b/probe/docker/tagger.go index 09b34d0ae..4582d70c1 100644 --- a/probe/docker/tagger.go +++ b/probe/docker/tagger.go @@ -78,7 +78,7 @@ func (t *Tagger) tag(tree process.Tree, topology *report.Topology) { } }) - if c == nil { + if c == nil || c.State() == StateStopped || c.PID() == 1 { continue }