Skip to content

Commit 2d8ead4

Browse files
meisterTnickygerritsen
authored andcommitted
Add cgroupv2 support.
Fixes #1072. Also move our integration tests from broken gitlab to working github actions.
1 parent 4949165 commit 2d8ead4

File tree

9 files changed

+325
-394
lines changed

9 files changed

+325
-394
lines changed

.github/jobs/baseinstall.sh

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,25 @@ section_end
2424

2525
section_start "Install domserver"
2626
make configure
27-
./configure \
28-
--with-baseurl='https://localhost/domjudge/' \
29-
--with-domjudge-user=root \
30-
--enable-doc-build=no \
31-
--enable-judgehost-build=no | tee "$ARTIFACTS"/configure.txt
32-
33-
make domserver
34-
make install-domserver
27+
if [ "$version" = "all" ]; then
28+
# Note that we use http instead of https here as python requests doesn't
29+
# like our self-signed cert. We should fix this separately.
30+
./configure \
31+
--with-baseurl='http://localhost/domjudge/' \
32+
--with-domjudge-user=domjudge \
33+
--with-judgehost-chrootdir=/chroot/domjudge | tee "$ARTIFACTS"/configure.txt
34+
make build-scripts domserver judgehost docs
35+
make install-domserver install-judgehost install-docs
36+
else
37+
./configure \
38+
--with-baseurl='https://localhost/domjudge/' \
39+
--with-domjudge-user=root \
40+
--enable-doc-build=no \
41+
--enable-judgehost-build=no | tee "$ARTIFACTS"/configure.txt
42+
make domserver
43+
make install-domserver
44+
fi
45+
3546
section_end
3647

3748
section_start "SQL settings"
@@ -122,6 +133,10 @@ elif [ "$version" = "balloon" ]; then
122133
elif [ "$version" = "admin" ]; then
123134
# Add admin to admin user
124135
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 1);" domjudge
136+
elif [ "$version" = "all" ]; then
137+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 1);" domjudge
138+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 3);" domjudge
139+
mysql_root "UPDATE user SET teamid = 1 WHERE userid = 1;" domjudge
125140
fi
126141
section_end
127142

.github/workflows/integration.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Run integration tests
2+
on:
3+
push:
4+
branches-ignore:
5+
- main
6+
- '[0-9]+.[0-9]+'
7+
- gh-readonly-queue/main/*
8+
- gh-readonly-queue/main/[0-9]+.[0-9]+
9+
pull_request:
10+
branches:
11+
- main
12+
- '[0-9]+.[0-9]+'
13+
14+
jobs:
15+
integration:
16+
runs-on: ubuntu-24.04
17+
container:
18+
image: domjudge/gitlabci:24.04
19+
options: --privileged --cgroupns=host --init
20+
services:
21+
sqlserver:
22+
image: mariadb
23+
ports:
24+
- 3306:3306
25+
env:
26+
MYSQL_ROOT_PASSWORD: root
27+
MYSQL_USER: domjudge
28+
MYSQL_PASSWORD: domjudge
29+
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
30+
steps:
31+
- uses: actions/checkout@v4
32+
- name: info
33+
run: |
34+
cat /proc/cmdline && echo &&
35+
cat /proc/mounts && echo &&
36+
ls -al /sys/fs/cgroup && echo &&
37+
uname -a && echo &&
38+
stat -fc %T /sys/fs/cgroup && echo &&
39+
cat /proc/self/cgroup && echo &&
40+
cat /proc/cpuinfo
41+
- name: pstree
42+
run: pstree -p
43+
- name: Install DOMjudge
44+
run: .github/jobs/baseinstall.sh all
45+
- name: Set up chroot
46+
run: sudo misc-tools/dj_make_chroot -a amd64
47+
- name: Check nginx
48+
run: curl -v https://localhost/domjudge/
49+
- name: Testing submit client
50+
working-directory: submit
51+
run: make check-full
52+
- name: Configure judgehost
53+
run: sudo cp /opt/domjudge/judgehost/etc/sudoers-domjudge /etc/sudoers.d/ && sudo chmod 400 /etc/sudoers.d/sudoers-domjudge && cat /opt/domjudge/judgehost/etc/sudoers-domjudge
54+
- name: Create user
55+
run: sudo userdel -f -r domjudge-run-0 ; sudo useradd -d /nonexistent -g nogroup -s /bin/false -u 2222 domjudge-run-0
56+
- name: Start judging
57+
run: sudo -u domjudge sh -c 'cd /opt/domjudge/judgehost/ && nohup bin/judgedaemon -n 0 &'
58+
- name: Import Kattis example problems
59+
run: |
60+
cd /tmp
61+
git clone --depth=1 https://github.com/Kattis/problemtools.git
62+
cd problemtools/examples
63+
mv hello hello_kattis
64+
# Remove 2 submissions that will not pass validation. The first is because it is
65+
# a Python 2 submission. The latter has a judgement type we do not understand.
66+
rm different/submissions/accepted/different_py2.py different/submissions/slow_accepted/different_slow.py
67+
for i in hello_kattis different guess; do
68+
(
69+
cd "$i"
70+
zip -r "../${i}.zip" -- *
71+
)
72+
curl --fail -X POST -n -N -F zip=@${i}.zip http://localhost/domjudge/api/contests/demo/problems
73+
done
74+
- name: Monitor judgehost log and stop once all submissions are judged
75+
run: |
76+
tail -f /opt/domjudge/judgehost/log/judge*-0.log | while read line; do
77+
echo "$line"
78+
grep "No submissions in queue" /opt/domjudge/judgehost/log/judge*-0.log && break
79+
done
80+
- name: dump the db
81+
run: mysqldump -uroot -proot domjudge > /tmp/db.sql
82+
- name: Upload artifact for debugging
83+
uses: actions/upload-artifact@v3
84+
with:
85+
name: DB-dump
86+
path: /tmp/db.sql
87+
- name: Verifying submissions
88+
shell: bash
89+
run: |
90+
set -x
91+
export CURLOPTS="--fail -sq -m 30 -b /tmp/cookiejar"
92+
# Make an initial request which will get us a session id, and grab the csrf token from it
93+
CSRFTOKEN=$(curl $CURLOPTS -c /tmp/cookiejar "http://localhost/domjudge/login" | sed -n 's/.*_csrf_token.*value="\(.*\)".*/\1/p')
94+
# Make a second request with our session + csrf token to actually log in
95+
curl $CURLOPTS -c /tmp/cookiejar -F "_csrf_token=$CSRFTOKEN" -F "_username=admin" -F "_password=password" "http://localhost/domjudge/login"
96+
# Send a general clarification to later test if we see the event.
97+
curl $CURLOPTS -F "sendto=" -F "problem=1-" -F "bodytext=Testing" -F "submit=Send" \
98+
"http://localhost/domjudge/jury/clarifications/send" -o /dev/null
99+
curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier?verify_multiple=1" -o /dev/null
100+
NUMNOTVERIFIED=$(curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier" | grep "submissions checked" | sed -r 's/^.* ([0-9]+) submissions checked.*$/\1/')
101+
NUMVERIFIED=$( curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier" | grep "submissions not checked" | sed -r 's/^.* ([0-9]+) submissions not checked.*$/\1/')
102+
NUMNOMAGIC=$( curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier" | grep "without magic string" | sed -r 's/^.* ([0-9]+) without magic string.*$/\1/')
103+
NUMSUBS=$(curl $CURLOPTS http://localhost/domjudge/api/contests/demo/submissions | python3 -mjson.tool | grep -c '"id":')
104+
# We expect
105+
# - two submissions with ambiguous outcome,
106+
# - one submissions submitted through the submit client, and thus the magic string ignored,
107+
# - and all submissions to be judged.
108+
if [ $NUMNOTVERIFIED -ne 2 ] || [ $NUMNOMAGIC -ne 1 ] || [ $NUMSUBS -gt $((NUMVERIFIED+NUMNOTVERIFIED)) ]; then
109+
echo "verified subs: $NUMVERIFIED, unverified subs: $NUMNOTVERIFIED, total subs: $NUMSUBS"
110+
echo "(expected 2 submissions to be unverified, but all to be processed)"
111+
echo "Of these $NUMNOMAGIC do not have the EXPECTED_RESULTS string (should be 1)."
112+
curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier?verify_multiple=1" | w3m -dump -T text/html
113+
exit 1
114+
fi
115+
- name: Finalize contest so that awards appear in the feed
116+
shell: bash
117+
run: |
118+
set -x
119+
export CURLOPTS="--fail -m 30 -b $COOKIEJAR"
120+
curl $CURLOPTS http://localhost/domjudge/jury/contests/1/freeze/doNow || true
121+
curl $CURLOPTS http://localhost/domjudge/jury/contests/1/end/doNow || true
122+
curl $CURLOPTS -X POST -d 'finalize_contest[b]=0&finalize_contest[finalizecomment]=gitlab&finalize_contest[finalize]=' http://localhost/domjudge/jury/contests/1/finalize
123+
- name: Verify no errors in prod.log
124+
shell: bash
125+
run: |
126+
if cat /opt/domjudge/domserver/webapp/var/log/prod.log | egrep '(CRITICAL|ERROR):'; then
127+
exit 1
128+
fi
129+
- name: Download and perform API check
130+
shell: bash
131+
run: |
132+
cd $HOME
133+
curl -o yajsv https://github.com/neilpa/yajsv/releases/download/v1.4.1/yajsv.linux.amd64
134+
chmod a+x yajsv
135+
echo -e "\033[0m"
136+
git clone https://github.com/icpc/ccs-specs.git
137+
export CCS_SPECS_PINNED_SHA1='a68aff54c4e60fc2bff2fc5c36c119bffa4d30f1'
138+
( cd ccs-specs && git reset --hard $CCS_SPECS_PINNED_SHA1 )
139+
export CHECK_API="${HOME}/ccs-specs/check-api.sh -j ${HOME}/yajsv"
140+
$CHECK_API -n -C -e -a 'strict=1' http://admin:password@localhost/domjudge/api

.github/workflows/runpipe.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run runpipe tests
1+
name: Run runpipe and runguard tests
22
on:
33
push:
44
branches-ignore:
@@ -13,11 +13,14 @@ on:
1313

1414
jobs:
1515
runpipe:
16-
runs-on: ubuntu-latest
16+
runs-on: ubuntu-24.04
1717
container:
1818
image: domjudge/gitlabci:24.04
19+
options: --privileged --cgroupns=host --init
1920
steps:
2021
- uses: actions/checkout@v4
22+
- name: info
23+
run: cat /proc/cmdline && echo && cat /proc/mounts && echo && ls -al /sys/fs/cgroup && echo && uname -a && echo && stat -fc %T /sys/fs/cgroup && echo && cat /proc/self/cgroup
2124
- name: Create the configure file
2225
run: make configure
2326
- name: Do the default configure
@@ -27,4 +30,14 @@ jobs:
2730
- name: Run the actual runpipe tests
2831
working-directory: judge/runpipe_test
2932
run: make test
33+
- name: Add user/group
34+
run: sudo addgroup domjudge-run-0 && sudo usermod -g domjudge-run-0 domjudge-run-0
35+
- name: Create dir
36+
run: mkdir -p /opt/domjudge/judgehost/tmp/
37+
- name: Run the actual runguard tests
38+
working-directory: judge/runguard_test
39+
env:
40+
judgehost_tmpdir: /tmp
41+
judgehost_judgedir: /tmp
42+
run: make test
3043

.gitlab-ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
include:
22
- '/gitlab/ci/unit.yml'
3-
- '/gitlab/ci/integration.yml'
43
- '/gitlab/ci/template.yml'
54
- '/gitlab/ci/misc.yml'
65

76
stages:
87
- test
9-
- integration
108
- chroot_checks
119
- unit
1210
- style

doc/manual/install-judgehost.rst

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,8 @@ Optionally the timings can be made more stable by not letting the OS schedule
179179
any other tasks on the same CPU core the judgedaemon is using:
180180
``GRUB_CMDLINE_LINUX_DEFAULT="quiet cgroup_enable=memory swapaccount=1 isolcpus=2"``
181181

182-
On modern distros (e.g. Debian bullseye and Ubuntu Jammy Jellyfish) which have
183-
cgroup v2 enabled by default, you need to add ``systemd.unified_cgroup_hierarchy=0``
184-
as well. Then run ``update-grub`` and reboot.
185-
After rebooting check that ``/proc/cmdline`` actually contains the
186-
added kernel options. On VM hosting providers such as Google Cloud or
187-
DigitalOcean, ``GRUB_CMDLINE_LINUX_DEFAULT`` may be overwritten
188-
by other files in ``/etc/default/grub.d/``.
189-
190-
You have now configured the system to use cgroups. To create
191-
the actual cgroups that DOMjudge will use, run::
182+
You have now configured the system to use cgroups. On systems with
183+
cgroups v1, you need to run::
192184

193185
sudo systemctl enable create-cgroups --now
194186

@@ -197,7 +189,8 @@ Note that this service will automatically be started if you use the
197189
customize the script ``judge/create_cgroups`` as required and run it
198190
after each boot.
199191

200-
The script `jvm_footprint` can be used to measure the memory overhead of the JVM for languages such as Kotlin and Java.
192+
The script `jvm_footprint` can be used to measure the memory overhead of the
193+
JVM for languages such as Kotlin and Java.
201194

202195

203196
REST API credentials

gitlab/ci/integration.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)