summaryrefslogtreecommitdiff
path: root/vendor/github.com/containerd/cgroups/systemd.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/containerd/cgroups/systemd.go')
-rw-r--r--vendor/github.com/containerd/cgroups/systemd.go34
1 files changed, 24 insertions, 10 deletions
diff --git a/vendor/github.com/containerd/cgroups/systemd.go b/vendor/github.com/containerd/cgroups/systemd.go
index 5e052a821..fd816e32e 100644
--- a/vendor/github.com/containerd/cgroups/systemd.go
+++ b/vendor/github.com/containerd/cgroups/systemd.go
@@ -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 {