From 6121f8b69f0914e796470f549e7e67f4e7d6879e Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 31 Mar 2021 11:38:32 -0700 Subject: [PATCH] libct/cg/fs2.Stat: always call statCpu Giuseppe found out that cpu.stat for a cgroup is available even if the cpu controller is not enabled for it. So, let's call statCpu regradress, and ignore ENOENT. Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/fs2/fs2.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libcontainer/cgroups/fs2/fs2.go b/libcontainer/cgroups/fs2/fs2.go index 733f9dcfd..c211f7596 100644 --- a/libcontainer/cgroups/fs2/fs2.go +++ b/libcontainer/cgroups/fs2/fs2.go @@ -130,10 +130,9 @@ func (m *manager) GetStats() (*cgroups.Stats, error) { } } // cpu (since kernel 4.15) - if _, ok := m.controllers["cpu"]; ok { - if err := statCpu(m.dirPath, st); err != nil { - errs = append(errs, err) - } + // Note cpu.stat is available even if the controller is not enabled. + if err := statCpu(m.dirPath, st); err != nil && !os.IsNotExist(err) { + errs = append(errs, err) } // hugetlb (since kernel 5.6) if _, ok := m.controllers["hugetlb"]; ok {