From 12f90dbd06580f4536c6dd1a74eafffac84ccd3a Mon Sep 17 00:00:00 2001 From: Andreas Kohn Date: Wed, 20 Sep 2023 22:10:48 +0200 Subject: [PATCH 1/3] Make sure all output goes to stderr --- judge/create_cgroups.in | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/judge/create_cgroups.in b/judge/create_cgroups.in index 1f9471d284..efa71a2633 100755 --- a/judge/create_cgroups.in +++ b/judge/create_cgroups.in @@ -10,7 +10,8 @@ JUDGEHOSTUSER=@DOMJUDGE_USER@ CGROUPBASE=@judgehost_cgroupdir@ print_cgroup_instruction () { - echo "" + echo "$1" >&2 + echo "" >&2 echo "To fix this, please make the following changes: 1. In /etc/default/grub, add 'cgroup_enable=memory swapaccount=1' to GRUB_CMDLINE_LINUX_DEFAULT. On modern distros (e.g. Debian bullseye and Ubuntu Jammy Jellyfish) which have cgroup v2 enabled by default, @@ -24,16 +25,14 @@ for i in cpuset memory; do mkdir -p $CGROUPBASE/$i if [ ! -d $CGROUPBASE/$i/ ]; then if ! mount -t cgroup -o$i $i $CGROUPBASE/$i/; then - echo "Error: Can not mount $i cgroup. Probably cgroup support is missing from running kernel. Unable to continue." - print_cgroup_instruction + print_cgroup_instruction "Error: Can not mount $i cgroup. Probably cgroup support is missing from running kernel. Unable to continue." fi fi mkdir -p $CGROUPBASE/$i/domjudge done if [ ! -f $CGROUPBASE/memory/memory.limit_in_bytes ] || [ ! -f $CGROUPBASE/memory/memory.memsw.limit_in_bytes ]; then - echo "Error: cgroup support missing memory features in running kernel. Unable to continue." - print_cgroup_instruction + print_cgroup_instruction "Error: cgroup support missing memory features in running kernel. Unable to continue." fi chown -R $JUDGEHOSTUSER $CGROUPBASE/*/domjudge From 593f99b27f22d69a78f4b3883eb5e09fc39e7892 Mon Sep 17 00:00:00 2001 From: Andreas Kohn Date: Wed, 20 Sep 2023 22:12:53 +0200 Subject: [PATCH 2/3] Remove unneeded newline --- judge/create_cgroups.in | 1 - 1 file changed, 1 deletion(-) diff --git a/judge/create_cgroups.in b/judge/create_cgroups.in index efa71a2633..16190991f2 100755 --- a/judge/create_cgroups.in +++ b/judge/create_cgroups.in @@ -11,7 +11,6 @@ CGROUPBASE=@judgehost_cgroupdir@ print_cgroup_instruction () { echo "$1" >&2 - echo "" >&2 echo "To fix this, please make the following changes: 1. In /etc/default/grub, add 'cgroup_enable=memory swapaccount=1' to GRUB_CMDLINE_LINUX_DEFAULT. On modern distros (e.g. Debian bullseye and Ubuntu Jammy Jellyfish) which have cgroup v2 enabled by default, From 52e13ee83f667a172bb00138f767cb3b9b77f382 Mon Sep 17 00:00:00 2001 From: Andreas Kohn Date: Thu, 21 Sep 2023 13:11:41 +0200 Subject: [PATCH 3/3] Rename function to match its (changed) behavior Suggested-by: @eldering --- judge/create_cgroups.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/judge/create_cgroups.in b/judge/create_cgroups.in index 16190991f2..fbfe48898b 100755 --- a/judge/create_cgroups.in +++ b/judge/create_cgroups.in @@ -9,7 +9,7 @@ JUDGEHOSTUSER=@DOMJUDGE_USER@ CGROUPBASE=@judgehost_cgroupdir@ -print_cgroup_instruction () { +cgroup_error_and_usage () { echo "$1" >&2 echo "To fix this, please make the following changes: 1. In /etc/default/grub, add 'cgroup_enable=memory swapaccount=1' to GRUB_CMDLINE_LINUX_DEFAULT. @@ -24,14 +24,14 @@ for i in cpuset memory; do mkdir -p $CGROUPBASE/$i if [ ! -d $CGROUPBASE/$i/ ]; then if ! mount -t cgroup -o$i $i $CGROUPBASE/$i/; then - print_cgroup_instruction "Error: Can not mount $i cgroup. Probably cgroup support is missing from running kernel. Unable to continue." + cgroup_error_and_usage "Error: Can not mount $i cgroup. Probably cgroup support is missing from running kernel. Unable to continue." fi fi mkdir -p $CGROUPBASE/$i/domjudge done if [ ! -f $CGROUPBASE/memory/memory.limit_in_bytes ] || [ ! -f $CGROUPBASE/memory/memory.memsw.limit_in_bytes ]; then - print_cgroup_instruction "Error: cgroup support missing memory features in running kernel. Unable to continue." + cgroup_error_and_usage "Error: cgroup support missing memory features in running kernel. Unable to continue." fi chown -R $JUDGEHOSTUSER $CGROUPBASE/*/domjudge