From b45db5d3b218aef2cfab59e2369430960a4312c0 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 26 Mar 2020 14:00:15 -0700 Subject: [PATCH] libcontainer/cgroup: obsolete Get*Cgroup for v2 These functions should not be called from any code handling the cgroup2 unified hierarchy. Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/utils.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libcontainer/cgroups/utils.go b/libcontainer/cgroups/utils.go index 7a465d526..7808c0936 100644 --- a/libcontainer/cgroups/utils.go +++ b/libcontainer/cgroups/utils.go @@ -4,6 +4,7 @@ package cgroups import ( "bufio" + "errors" "fmt" "io" "io/ioutil" @@ -28,6 +29,8 @@ const ( var ( isUnifiedOnce sync.Once isUnified bool + + errUnified = errors.New("not implemented for cgroup v2 unified hierarchy") ) // HugePageSizeUnitList is a list of the units used by the linux kernel when @@ -307,6 +310,9 @@ func GetAllSubsystems() ([]string, error) { // GetOwnCgroup returns the relative path to the cgroup docker is running in. func GetOwnCgroup(subsystem string) (string, error) { + if IsCgroup2UnifiedMode() { + return "", errUnified + } cgroups, err := ParseCgroupFile("/proc/self/cgroup") if err != nil { return "", err @@ -325,6 +331,9 @@ func GetOwnCgroupPath(subsystem string) (string, error) { } func GetInitCgroup(subsystem string) (string, error) { + if IsCgroup2UnifiedMode() { + return "", errUnified + } cgroups, err := ParseCgroupFile("/proc/1/cgroup") if err != nil { return "", err