Skip to content

Commit

Permalink
cgutil: handle panic from runc helper method
Browse files Browse the repository at this point in the history
This PR wraps the cgroups.IsCgroup2UnifiedMode() helper method from
runc in a defer/recover block because it might panic in some cases.

Upstream fix in: opencontainers/runc#3745

Closes #16179
  • Loading branch information
shoenig committed Feb 14, 2023
1 parent fd011ce commit 0f95667
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion client/lib/cgutil/cgutil_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,19 @@ import (
// cgroups.v1
//
// This is a read-only value.
var UseV2 = cgroups.IsCgroup2UnifiedMode()
var UseV2 = safelyDetectUnifiedMode()

// Currently it is possible for the runc utility function to panic
// https://github.com/opencontainers/runc/pull/3745
func safelyDetectUnifiedMode() (result bool) {
defer func() {
if r := recover(); r != nil {
result = false
}
}()
result = cgroups.IsCgroup2UnifiedMode()
return
}

// GetCgroupParent returns the mount point under the root cgroup in which Nomad
// will create cgroups. If parent is not set, an appropriate name for the version
Expand Down

0 comments on commit 0f95667

Please sign in to comment.