Skip to content

Commit

Permalink
libct/cg/fs2: fix GetStats for unsupported hugetlb
Browse files Browse the repository at this point in the history
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: 89a87ad
Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Oct 5, 2021
1 parent 8e7ab26 commit 916c6a1
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions libcontainer/cgroups/fs2/hugetlb.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package fs2

import (
"fmt"
"strconv"

"github.com/opencontainers/runc/libcontainer/cgroups"
Expand All @@ -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 {
Expand Down

0 comments on commit 916c6a1

Please sign in to comment.