Skip to content

Commit cb04f03

Browse files
committed
Merge pull request opencontainers#336 from hqhq/hq_parent_cgroup_systemd
systemd: support cgroup parent with specified slice
2 parents 6672d63 + 7695a0d commit cb04f03

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

libcontainer/cgroups/systemd/apply_systemd.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ func (m *Manager) Apply(pid int) error {
167167
properties []systemdDbus.Property
168168
)
169169

170-
if c.Slice != "" {
171-
slice = c.Slice
170+
if c.Parent != "" {
171+
slice = c.Parent
172172
}
173173

174174
properties = append(properties,
@@ -406,8 +406,8 @@ func getSubsystemPath(c *configs.Cgroup, subsystem string) (string, error) {
406406
}
407407

408408
slice := "system.slice"
409-
if c.Slice != "" {
410-
slice = c.Slice
409+
if c.Parent != "" {
410+
slice = c.Parent
411411
}
412412

413413
return filepath.Join(mountpoint, initPath, slice, getUnitName(c)), nil
@@ -472,7 +472,7 @@ func (m *Manager) Set(container *configs.Config) error {
472472
}
473473

474474
func getUnitName(c *configs.Cgroup) string {
475-
return fmt.Sprintf("%s-%s.scope", c.Parent, c.Name)
475+
return fmt.Sprintf("%s-%s.scope", c.ScopePrefix, c.Name)
476476
}
477477

478478
// Atm we can't use the systemd device support because of two missing things:

libcontainer/configs/cgroup_unix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ type Cgroup struct {
8383
// Hugetlb limit (in bytes)
8484
HugetlbLimit []*HugepageLimit `json:"hugetlb_limit"`
8585

86-
// Parent slice to use for systemd TODO: remove in favor or parent
87-
Slice string `json:"slice"`
86+
// ScopePrefix decribes prefix for the scope name
87+
ScopePrefix string `json:"scope_prefix"`
8888

8989
// Whether to disable OOM Killer
9090
OomKillDisable bool `json:"oom_kill_disable"`

libcontainer/integration/exec_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ func testCpuShares(t *testing.T, systemd bool) {
515515

516516
config := newTemplateConfig(rootfs)
517517
if systemd {
518-
config.Cgroups.Slice = "system.slice"
518+
config.Cgroups.Parent = "system.slice"
519519
}
520520
config.Cgroups.CpuShares = 1
521521

@@ -546,7 +546,7 @@ func testRunWithKernelMemory(t *testing.T, systemd bool) {
546546

547547
config := newTemplateConfig(rootfs)
548548
if systemd {
549-
config.Cgroups.Slice = "system.slice"
549+
config.Cgroups.Parent = "system.slice"
550550
}
551551
config.Cgroups.KernelMemory = 52428800
552552

libcontainer/integration/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func copyBusybox(dest string) error {
9494
func newContainer(config *configs.Config) (libcontainer.Container, error) {
9595
f := factory
9696

97-
if config.Cgroups != nil && config.Cgroups.Slice == "system.slice" {
97+
if config.Cgroups != nil && config.Cgroups.Parent == "system.slice" {
9898
f = systemdFactory
9999
}
100100

0 commit comments

Comments
 (0)