From 5785aabc13b857edcb9c38ee92ccbf3719abdc92 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 15 May 2020 12:26:42 -0700 Subject: [PATCH] libct/cgroups: make isSubsystemAvailable v1-specific This function is only called from cgroupv1 code, so there is no need for it to implement cgroupv2 stuff. Make it v1-specific, and panic if it is called from v2 code (since this is an internal function, the panic would mean incorrect runc code). Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/utils.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/libcontainer/cgroups/utils.go b/libcontainer/cgroups/utils.go index 8f77522e7..a6b96d9fb 100644 --- a/libcontainer/cgroups/utils.go +++ b/libcontainer/cgroups/utils.go @@ -106,16 +106,7 @@ func findCgroupMountpointAndRootFromReader(reader io.Reader, cgroupPath, subsyst func isSubsystemAvailable(subsystem string) bool { if IsCgroup2UnifiedMode() { - controllers, err := GetAllSubsystems() - if err != nil { - return false - } - for _, c := range controllers { - if c == subsystem { - return true - } - } - return false + panic("don't call isSubsystemAvailable from cgroupv2 code") } cgroups, err := ParseCgroupFile("/proc/self/cgroup")