Skip to content

Commit b272039

Browse files
committed
Improve cgroup error message when not configured correctly.
1 parent cd068c5 commit b272039

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

judge/create_cgroups.in

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ CGROUPBASE="/sys/fs/cgroup"
1111

1212
cgroup_error_and_usage () {
1313
echo "$1" >&2
14-
echo "To fix this, please make the following changes:
14+
echo "Unable to continue. To fix this, you most likely need to follow these steps:
1515
1. In /etc/default/grub, add 'cgroup_enable=memory swapaccount=1' to GRUB_CMDLINE_LINUX_DEFAULT.
1616
2. Run update-grub
1717
3. Reboot" >&2
@@ -29,10 +29,13 @@ if [ "$fs_type" = "cgroup2" ]; then
2929
You can try using cgroup V1 by adding systemd.unified_cgroup_hierarchy=0 to the kernel params."
3030
fi
3131
if ! echo "+memory" >> /sys/fs/cgroup/cgroup.subtree_control; then
32-
cgroup_error_and_usage "Error: Cannot add +memory to cgroup.subtree_control; check kernel params. Unable to continue."
32+
cgroup_error_and_usage "Error: Cannot add +memory to cgroup.subtree_control; check kernel params."
3333
fi
3434
if ! echo "+cpuset" >> /sys/fs/cgroup/cgroup.subtree_control; then
35-
cgroup_error_and_usage "Error: Cannot add +cpuset to cgroup.subtree_control; check kernel params. Unable to continue."
35+
cgroup_error_and_usage "Error: Cannot add +cpuset to cgroup.subtree_control; check kernel params."
36+
fi
37+
if ! grep -q "slice" /proc/self/cgroup; then
38+
cgroup_error_and_usage "Error: Cgroups not configured properly, missing systemd slice under /proc/self/cgroup. If running under docker, make sure to set cgroupns=host."
3639
fi
3740

3841
else # Trying cgroup V1:
@@ -41,14 +44,14 @@ else # Trying cgroup V1:
4144
mkdir -p $CGROUPBASE/$i
4245
if [ ! -d $CGROUPBASE/$i/ ]; then
4346
if ! mount -t cgroup -o$i $i $CGROUPBASE/$i/; then
44-
cgroup_error_and_usage "Error: Can not mount $i cgroup. Probably cgroup support is missing from running kernel. Unable to continue."
47+
cgroup_error_and_usage "Error: Can not mount $i cgroup. Probably cgroup support is missing from running kernel."
4548
fi
4649
fi
4750
mkdir -p $CGROUPBASE/$i/domjudge
4851
done
4952

5053
if [ ! -f $CGROUPBASE/memory/memory.limit_in_bytes ] || [ ! -f $CGROUPBASE/memory/memory.memsw.limit_in_bytes ]; then
51-
cgroup_error_and_usage "Error: cgroup support missing memory features in running kernel. Unable to continue."
54+
cgroup_error_and_usage "Error: cgroup support missing memory features in running kernel."
5255
fi
5356

5457
chown -R $JUDGEHOSTUSER $CGROUPBASE/*/domjudge

0 commit comments

Comments
 (0)