Skip to content

Commit c1aa57f

Browse files
author
saville
committed
Add validation in case cgroup2 is not enabled on linux
1 parent f0dd4d1 commit c1aa57f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

buildrunner/docker/runner.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import datetime
1111
import io
1212
import os.path
13+
import platform
1314
import socket
1415
import ssl
1516
from collections import OrderedDict
@@ -179,6 +180,14 @@ def start(
179180
# If we are running in a systemd context, the following 3 settings are necessary to
180181
# allow services to run.
181182
if systemd_cgroup2:
183+
# Ensure that cgroup v2 is supported before attempting to use it
184+
# Note: this check only works on linux systems
185+
if platform.system() == "Linux" and not os.path.exists(
186+
"/sys/fs/cgroup/cgroup.controllers"
187+
):
188+
raise BuildRunnerContainerError(
189+
"cgroup v2 is not enabled on this host but is set on the container, please check configuration"
190+
)
182191
volumes["/sys/fs/cgroup/buildrunner.scope"] = "/sys/fs/cgroup:rw"
183192
tmpfs["/run"] = ""
184193
cgroupns = "host"

0 commit comments

Comments
 (0)