Skip to content

Commit

Permalink
merge branch 'pr-2634'
Browse files Browse the repository at this point in the history
Cory Bennett (1):
  don't panic when /sys/fs/cgroup is missing for rootless

LGTMs: @AkihiroSuda @cyphar
Closes #2634
  • Loading branch information
cyphar committed Oct 29, 2020
2 parents 2a495f9 + 3369d25 commit d9006f3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libcontainer/cgroups/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"time"

"github.com/opencontainers/runc/libcontainer/cgroups/fscommon"
"github.com/opencontainers/runc/libcontainer/system"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
)
Expand All @@ -34,8 +35,15 @@ var (
func IsCgroup2UnifiedMode() bool {
isUnifiedOnce.Do(func() {
var st unix.Statfs_t
if err := unix.Statfs(unifiedMountpoint, &st); err != nil {
panic("cannot statfs cgroup root")
err := unix.Statfs(unifiedMountpoint, &st)
if err != nil {
if os.IsNotExist(err) && system.RunningInUserNS() {
// ignore the "not found" error if running in userns
logrus.WithError(err).Debugf("%s missing, assuming cgroup v1", unifiedMountpoint)
isUnified = false
return
}
panic(fmt.Sprintf("cannot statfs cgroup root: %s", err))
}
isUnified = st.Type == unix.CGROUP2_SUPER_MAGIC
})
Expand Down

0 comments on commit d9006f3

Please sign in to comment.