From 8e96a96ff5422fb68eb2b14a843e2baf7242f2bf Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 5 Oct 2021 16:48:15 -0700 Subject: [PATCH] libct/cg/fs2: fix GetStats for unsupported hugetlb In case hugetlb is not supported, GetStats() should not error out, and yet it does. Assume that if GetHugePageSize return an error, hugetlb is not supported (this is what cgroup v1 manager do). Fixes: 89a87adb Signed-off-by: Kir Kolyshkin (cherry picked from commit 916c6a15397451e8d39f8d3f0134d9cfc776cb96) Signed-off-by: Akihiro Suda --- libcontainer/cgroups/fs2/hugetlb.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libcontainer/cgroups/fs2/hugetlb.go b/libcontainer/cgroups/fs2/hugetlb.go index 3f513975bd3..96390a224f1 100644 --- a/libcontainer/cgroups/fs2/hugetlb.go +++ b/libcontainer/cgroups/fs2/hugetlb.go @@ -30,10 +30,7 @@ func setHugeTlb(dirPath string, r *configs.Resources) error { } func statHugeTlb(dirPath string, stats *cgroups.Stats) error { - hugePageSizes, err := cgroups.GetHugePageSize() - if err != nil { - return errors.Wrap(err, "failed to fetch hugetlb info") - } + hugePageSizes, _ := cgroups.GetHugePageSize() hugetlbStats := cgroups.HugetlbStats{} for _, pagesize := range hugePageSizes {