From 8d7977ee6eadd60a7007337c016e04e0ebda2ad6 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 31 Mar 2020 18:24:44 -0700 Subject: [PATCH] libct/isPaused: don't use GetPaths from v2 code Using GetPaths from cgroupv2 unified hierarchy code is deprecated and this function will (hopefully) be removed. Use GetUnifiedPath() for v2 case. Signed-off-by: Kir Kolyshkin --- libcontainer/container_linux.go | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/libcontainer/container_linux.go b/libcontainer/container_linux.go index aa150244e7d..d8222b2b531 100644 --- a/libcontainer/container_linux.go +++ b/libcontainer/container_linux.go @@ -1822,14 +1822,23 @@ func (c *linuxContainer) runType() Status { } func (c *linuxContainer) isPaused() (bool, error) { - fcg := c.cgroupManager.GetPaths()["freezer"] - if fcg == "" { - // A container doesn't have a freezer cgroup - return false, nil - } - pausedState := "FROZEN" - filename := "freezer.state" - if cgroups.IsCgroup2UnifiedMode() { + var fcg, filename, pausedState string + + if !cgroups.IsCgroup2UnifiedMode() { + fcg = c.cgroupManager.GetPaths()["freezer"] + if fcg == "" { + // A container doesn't have a freezer cgroup + return false, nil + } + filename = "freezer.state" + pausedState = "FROZEN" + } else { + var err error + fcg, err = c.cgroupManager.GetUnifiedPath() + if err != nil { + // should not happen + return false, err + } filename = "cgroup.freeze" pausedState = "1" }