systemd: support cgroup parent with specified slice
Pick up #119 Fixes: docker/docker#16681 Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
parent
3317785f56
commit
7695a0ddb0
|
@ -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:
|
||||
|
|
|
@ -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"`
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue