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:
package fs2
import (
- "fmt"
"strconv"
"github.com/opencontainers/runc/libcontainer/cgroups"
@@ -27,10 +26,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 fmt.Errorf("failed to fetch hugetlb info: %w", err)
- }
+ hugePageSizes, _ := cgroups.GetHugePageSize()
hugetlbStats := cgroups.HugetlbStats{}
for _, pagesize := range hugePageSizes {
