From 27bb1bd5ea7645e3b405ddc74901d295de2e0e32 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 1 Apr 2021 19:33:57 -0700 Subject: [PATCH] libct/specconv/CreateCgroupConfig: don't set c.Parent default c.Parent is only used by systemd cgroup drivers, and both v1 and v2 drivers do have code to set the default if it is empty, so setting it here is redundant. In addition, in case of cgroup v2 rootless container setting it here is harmful as the default should be user.slice not system.slice. Signed-off-by: Kir Kolyshkin --- libcontainer/specconv/spec_linux.go | 2 +- libcontainer/specconv/spec_linux_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libcontainer/specconv/spec_linux.go b/libcontainer/specconv/spec_linux.go index 16e9bac6c..125f79547 100644 --- a/libcontainer/specconv/spec_linux.go +++ b/libcontainer/specconv/spec_linux.go @@ -445,7 +445,7 @@ func CreateCgroupConfig(opts *CreateOpts, defaultDevs []*devices.Device) (*confi if useSystemdCgroup { if myCgroupPath == "" { - c.Parent = "system.slice" + // Default for c.Parent is set by systemd cgroup drivers. c.ScopePrefix = "runc" c.Name = name } else { diff --git a/libcontainer/specconv/spec_linux_test.go b/libcontainer/specconv/spec_linux_test.go index dc880f32c..f4dc860fe 100644 --- a/libcontainer/specconv/spec_linux_test.go +++ b/libcontainer/specconv/spec_linux_test.go @@ -345,7 +345,7 @@ func TestLinuxCgroupSystemdWithEmptyPath(t *testing.T) { t.Errorf("Couldn't create Cgroup config: %v", err) } - expectedParent := "system.slice" + expectedParent := "" if cgroup.Parent != expectedParent { t.Errorf("Expected to have %s as Parent instead of %s", expectedParent, cgroup.Parent) }