metrics/cgroups: handle error on call to cgroup

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day
2017-10-06 15:48:06 -07:00
parent 987fcd1201
commit 77e5f6553c
2 changed files with 11 additions and 3 deletions

View File

@@ -75,7 +75,14 @@ func (m *cgroupsMonitor) Monitor(c runtime.Task) error {
func (m *cgroupsMonitor) Stop(c runtime.Task) error {
info := c.Info()
t := c.(*linux.Task)
m.collector.collect(info.ID, info.Namespace, t.Cgroup(), m.collector.storedMetrics, false, nil)
cgroup, err := t.Cgroup()
if err != nil {
log.G(m.context).WithError(err).Warnf("unable to retrieve cgroup on stop")
} else {
m.collector.collect(info.ID, info.Namespace, cgroup, m.collector.storedMetrics, false, nil)
}
m.collector.Remove(info.ID, info.Namespace)
return nil
}