Merge pull request #336 from hqhq/hq_parent_cgroup_systemd

systemd: support cgroup parent with specified slice
This commit is contained in:
Alexander Morozov 2015-12-11 10:13:47 -08:00
commit cb04f03854
4 changed files with 10 additions and 10 deletions

View File

@ -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:

View File

@ -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"`

View File

@ -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

View File

@ -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
}