diff --git a/.changelog/16180.txt b/.changelog/16180.txt new file mode 100644 index 000000000..265d62404 --- /dev/null +++ b/.changelog/16180.txt @@ -0,0 +1,3 @@ +```release-note:bug +cgutil: handle panic coming from runc helper method +``` diff --git a/client/lib/cgutil/cgutil_linux.go b/client/lib/cgutil/cgutil_linux.go index 178b65b7b..84ce6b408 100644 --- a/client/lib/cgutil/cgutil_linux.go +++ b/client/lib/cgutil/cgutil_linux.go @@ -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