diff --git a/libcontainer/cgroups/systemd/apply_systemd.go b/libcontainer/cgroups/systemd/apply_systemd.go index 7a422b3c7..41b6fbcd8 100644 --- a/libcontainer/cgroups/systemd/apply_systemd.go +++ b/libcontainer/cgroups/systemd/apply_systemd.go @@ -167,8 +167,8 @@ func (m *Manager) Apply(pid int) error { properties []systemdDbus.Property ) - if c.Slice != "" { - slice = c.Slice + if c.Parent != "" { + slice = c.Parent } properties = append(properties, @@ -406,8 +406,8 @@ func getSubsystemPath(c *configs.Cgroup, subsystem string) (string, error) { } slice := "system.slice" - if c.Slice != "" { - slice = c.Slice + if c.Parent != "" { + slice = c.Parent } return filepath.Join(mountpoint, initPath, slice, getUnitName(c)), nil @@ -472,7 +472,7 @@ func (m *Manager) Set(container *configs.Config) error { } func getUnitName(c *configs.Cgroup) string { - return fmt.Sprintf("%s-%s.scope", c.Parent, c.Name) + return fmt.Sprintf("%s-%s.scope", c.ScopePrefix, c.Name) } // Atm we can't use the systemd device support because of two missing things: diff --git a/libcontainer/configs/cgroup_unix.go b/libcontainer/configs/cgroup_unix.go index 24f93c1ad..f256fa247 100644 --- a/libcontainer/configs/cgroup_unix.go +++ b/libcontainer/configs/cgroup_unix.go @@ -83,8 +83,8 @@ type Cgroup struct { // Hugetlb limit (in bytes) HugetlbLimit []*HugepageLimit `json:"hugetlb_limit"` - // Parent slice to use for systemd TODO: remove in favor or parent - Slice string `json:"slice"` + // ScopePrefix decribes prefix for the scope name + ScopePrefix string `json:"scope_prefix"` // Whether to disable OOM Killer OomKillDisable bool `json:"oom_kill_disable"` diff --git a/libcontainer/integration/exec_test.go b/libcontainer/integration/exec_test.go index 00306f176..0cb133aa0 100644 --- a/libcontainer/integration/exec_test.go +++ b/libcontainer/integration/exec_test.go @@ -515,7 +515,7 @@ func testCpuShares(t *testing.T, systemd bool) { config := newTemplateConfig(rootfs) if systemd { - config.Cgroups.Slice = "system.slice" + config.Cgroups.Parent = "system.slice" } config.Cgroups.CpuShares = 1 @@ -546,7 +546,7 @@ func testRunWithKernelMemory(t *testing.T, systemd bool) { config := newTemplateConfig(rootfs) if systemd { - config.Cgroups.Slice = "system.slice" + config.Cgroups.Parent = "system.slice" } config.Cgroups.KernelMemory = 52428800 diff --git a/libcontainer/integration/utils_test.go b/libcontainer/integration/utils_test.go index 1fc2da4d6..7773665b2 100644 --- a/libcontainer/integration/utils_test.go +++ b/libcontainer/integration/utils_test.go @@ -94,7 +94,7 @@ func copyBusybox(dest string) error { func newContainer(config *configs.Config) (libcontainer.Container, error) { f := factory - if config.Cgroups != nil && config.Cgroups.Slice == "system.slice" { + if config.Cgroups != nil && config.Cgroups.Parent == "system.slice" { f = systemdFactory }