Update containerd/cgroups repo fix perf issue

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
This commit is contained in:
Matthew Heon
2018-02-01 12:55:28 -05:00
parent 03cfe5ebbe
commit ae89dc28d0
15 changed files with 4074 additions and 221 deletions

View File

@ -43,19 +43,13 @@ func Slice(slice, name string) Path {
}
func NewSystemd(root string) (*SystemdController, error) {
conn, err := systemdDbus.New()
if err != nil {
return nil, err
}
return &SystemdController{
root: root,
conn: conn,
}, nil
}
type SystemdController struct {
mu sync.Mutex
conn *systemdDbus.Conn
root string
}
@ -64,6 +58,11 @@ func (s *SystemdController) Name() Name {
}
func (s *SystemdController) Create(path string, resources *specs.LinuxResources) error {
conn, err := systemdDbus.New()
if err != nil {
return err
}
defer conn.Close()
slice, name := splitName(path)
properties := []systemdDbus.Property{
systemdDbus.PropDescription(fmt.Sprintf("cgroup %s", name)),
@ -74,14 +73,29 @@ func (s *SystemdController) Create(path string, resources *specs.LinuxResources)
newProperty("CPUAccounting", true),
newProperty("BlockIOAccounting", true),
}
_, err := s.conn.StartTransientUnit(name, "replace", properties, nil)
return err
ch := make(chan string)
_, err = conn.StartTransientUnit(name, "replace", properties, ch)
if err != nil {
return err
}
<-ch
return nil
}
func (s *SystemdController) Delete(path string) error {
conn, err := systemdDbus.New()
if err != nil {
return err
}
defer conn.Close()
_, name := splitName(path)
_, err := s.conn.StopUnit(name, "replace", nil)
return err
ch := make(chan string)
_, err = conn.StopUnit(name, "replace", ch)
if err != nil {
return err
}
<-ch
return nil
}
func newProperty(name string, units interface{}) systemdDbus.Property {