metrics/cgroups: handle error on call to cgroup
Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
		| @@ -75,7 +75,14 @@ func (m *cgroupsMonitor) Monitor(c runtime.Task) error { | |||||||
| func (m *cgroupsMonitor) Stop(c runtime.Task) error { | func (m *cgroupsMonitor) Stop(c runtime.Task) error { | ||||||
| 	info := c.Info() | 	info := c.Info() | ||||||
| 	t := c.(*linux.Task) | 	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) | 	m.collector.Remove(info.ID, info.Namespace) | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|   | |||||||
| @@ -8,9 +8,9 @@ import ( | |||||||
| 	"sync" | 	"sync" | ||||||
|  |  | ||||||
| 	"github.com/containerd/cgroups" | 	"github.com/containerd/cgroups" | ||||||
|  | 	"github.com/containerd/containerd/log" | ||||||
| 	metrics "github.com/docker/go-metrics" | 	metrics "github.com/docker/go-metrics" | ||||||
| 	"github.com/prometheus/client_golang/prometheus" | 	"github.com/prometheus/client_golang/prometheus" | ||||||
| 	"github.com/sirupsen/logrus" |  | ||||||
| ) | ) | ||||||
|  |  | ||||||
| var ( | var ( | ||||||
| @@ -97,9 +97,10 @@ func (c *collector) collect(id, namespace string, cg cgroups.Cgroup, ch chan<- p | |||||||
| 	if wg != nil { | 	if wg != nil { | ||||||
| 		defer wg.Done() | 		defer wg.Done() | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	stats, err := cg.Stat(cgroups.IgnoreNotExist) | 	stats, err := cg.Stat(cgroups.IgnoreNotExist) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		logrus.WithError(err).Errorf("stat cgroup %s", id) | 		log.L.WithError(err).Errorf("stat cgroup %s", id) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	for _, m := range c.metrics { | 	for _, m := range c.metrics { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Stephen J Day
					Stephen J Day