Namespace cgroups monitor ids

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2017-06-08 16:46:13 -07:00
parent 745398b2e9
commit a40f307e88
2 changed files with 8 additions and 2 deletions

View File

@ -3,6 +3,7 @@
package cgroups package cgroups
import ( import (
"fmt"
"time" "time"
"github.com/containerd/cgroups" "github.com/containerd/cgroups"
@ -45,8 +46,12 @@ type cgroupsMonitor struct {
events chan<- *plugin.Event events chan<- *plugin.Event
} }
func getID(t plugin.Task) string {
return fmt.Sprintf("%s-%s", t.Info().ID, t.Info().Namespace)
}
func (m *cgroupsMonitor) Monitor(c plugin.Task) error { func (m *cgroupsMonitor) Monitor(c plugin.Task) error {
id := c.Info().ID id := getID(c)
state, err := c.State(m.context) state, err := c.State(m.context)
if err != nil { if err != nil {
return err return err
@ -62,7 +67,7 @@ func (m *cgroupsMonitor) Monitor(c plugin.Task) error {
} }
func (m *cgroupsMonitor) Stop(c plugin.Task) error { func (m *cgroupsMonitor) Stop(c plugin.Task) error {
m.collector.Remove(c.Info().ID) m.collector.Remove(getID(c))
return nil return nil
} }

View File

@ -155,6 +155,7 @@ func createDefaultSpec() (*specs.Spec, error) {
}, },
}, },
Linux: &specs.Linux{ Linux: &specs.Linux{
// TODO (@crosbymichael) make sure we don't have have two containers in the same cgroup
Resources: &specs.LinuxResources{ Resources: &specs.LinuxResources{
Devices: []specs.LinuxDeviceCgroup{ Devices: []specs.LinuxDeviceCgroup{
{ {