Skip to content

Commit

Permalink
Merge pull request #3827 from kolyshkin/no-panic
Browse files Browse the repository at this point in the history
libct/cg: IsCgroup2UnifiedMode: don't panic
  • Loading branch information
thaJeztah authored Jun 28, 2023
2 parents 17b335a + 5cdf767 commit f9bd4a5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libcontainer/cgroups/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ func IsCgroup2UnifiedMode() bool {
var st unix.Statfs_t
err := unix.Statfs(unifiedMountpoint, &st)
if err != nil {
level := logrus.WarnLevel
if os.IsNotExist(err) && userns.RunningInUserNS() {
// ignore the "not found" error if running in userns
logrus.WithError(err).Debugf("%s missing, assuming cgroup v1", unifiedMountpoint)
isUnified = false
return
// For rootless containers, sweep it under the rug.
level = logrus.DebugLevel
}
panic(fmt.Sprintf("cannot statfs cgroup root: %s", err))
logrus.StandardLogger().Logf(level,
"statfs %s: %v; assuming cgroup v1", unifiedMountpoint, err)
}
isUnified = st.Type == unix.CGROUP2_SUPER_MAGIC
})
Expand Down

0 comments on commit f9bd4a5

Please sign in to comment.