Skip to content

Commit b1429a8

Browse files
authored
Merge branch 'main' into analyst-eval
2 parents ca69da5 + 5c5b651 commit b1429a8

File tree

83 files changed

+1281
-354
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1281
-354
lines changed

.github/jobs/fix_pipelinecomponents_image.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ set -eux
88

99
echo "Set plugin config for version detection"
1010
phpcs --config-set installed_paths /app/vendor/phpcompatibility/php-compatibility
11-
11+
1212
# Current released version does not know enums
1313
echo "Upgrade the compatibility for PHP versions"
1414
mydir=$(pwd)
1515
sed -i 's/"phpcompatibility\/php-compatibility": "9.3.5"/"phpcompatibility\/php-compatibility": "dev-develop"/g' /app/composer.json
16+
sed -i 's/"squizlabs\/php_codesniffer": "3.11.3"/"squizlabs\/php_codesniffer": "^3.13.0"/g' /app/composer.json
1617
cd /app; composer update
1718
cd $mydir

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
with:
9797
dest: '/tmp/docker-logs'
9898
- name: Upload all logs/artifacts
99-
if: ${{ !cancelled() }}
99+
if: always()
100100
uses: actions/upload-artifact@v4
101101
with:
102102
name: Logs

.github/workflows/phpstan.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ jobs:
1515
run: .github/jobs/composer_setup.sh
1616
- name: Show the phpstan version
1717
run: webapp/vendor/phpstan/phpstan/phpstan --version
18+
- name: Run PHPStan in the classic way
19+
run: |
20+
set -euo pipefail
21+
webapp/vendor/bin/phpstan \
22+
--configuration=webapp/phpstan.dist.neon \
23+
| tee /tmp/artifacts/phpstan.out
24+
# Run the test again for GHA annotations
1825
- uses: php-actions/[email protected]
1926
with:
2027
configuration: webapp/phpstan.dist.neon
21-
path: webapp/src webapp/tests
2228
php_extensions: gd intl mysqli pcntl zip
2329
autoload_file: webapp/vendor/autoload.php
2430
version: composer

Makefile

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ REC_TARGETS=build domserver install-domserver judgehost install-judgehost \
1111
# Global Makefile definitions
1212
include $(TOPDIR)/Makefile.global
1313

14+
debpool := /etc/php/$(PHPVERSION)/fpm/pool.d
15+
fedpool := /etc/php-fpm.d
16+
1417
default:
1518
@echo "No default target"
1619
@echo
@@ -238,6 +241,8 @@ inplace-install-l:
238241
@echo " sudo make inplace-postinstall-apache"
239242
@echo " - Configure nginx"
240243
@echo " sudo make inplace-postinstall-nginx"
244+
@echo " - Configure judgedaemon"
245+
@echo " sudo make inplace-postinstall-judgedaemon"
241246
@echo " - Set up database"
242247
@echo " ./sql/dj_setup_database -u root [-r|-p ROOT_PASS] install"
243248
@echo ""
@@ -275,6 +280,14 @@ inplace-postinstall-permissions:
275280
setfacl -R -m u:$(DOMJUDGE_USER):rwx $(CURDIR)/webapp/var
276281
setfacl -R -m d:m::rwx $(CURDIR)/webapp/var
277282
setfacl -R -m m::rwx $(CURDIR)/webapp/var
283+
if command -v sestatus >/dev/null 2>&1; then \
284+
chcon -R -t httpd_sys_content_t $(CURDIR)/webapp; \
285+
chcon -R -t httpd_config_t $(CURDIR)/etc; \
286+
chcon -R -t httpd_log_t $(CURDIR)/webapp/var/log; \
287+
chcon -R -t httpd_sys_rw_content_t $(CURDIR)/webapp/var/cache; \
288+
chcon -R -t httpd_sys_rw_content_t $(CURDIR)/webapp/public/images; \
289+
chcon -t httpd_exec_t $(CURDIR)/lib/alert; \
290+
fi
278291

279292
inplace-postinstall-apache: inplace-postinstall-permissions
280293
@if [ ! -d "/etc/apache2/conf-enabled" ]; then echo "Couldn't find directory /etc/apache2/conf-enabled. Is apache installed?"; false; fi
@@ -284,12 +297,28 @@ inplace-postinstall-apache: inplace-postinstall-permissions
284297
systemctl restart apache2
285298

286299
inplace-postinstall-nginx: inplace-postinstall-permissions
287-
@if [ ! -d "/etc/nginx/sites-enabled/" ]; then echo "Couldn't find directory /etc/nginx/sites-enabled/. Is nginx installed?"; false; fi
288-
@if [ ! -d "/etc/php/$(PHPVERSION)/fpm/pool.d/" ]; then echo "Couldn't find directory /etc/php/$(PHPVERSION)/fpm/pool.d/. Is php-fpm installed?"; false; fi
289-
ln -sf $(CURDIR)/etc/nginx-conf /etc/nginx/sites-enabled/domjudge.conf
290-
ln -sf $(CURDIR)/etc/domjudge-fpm.conf /etc/php/$(PHPVERSION)/fpm/pool.d/domjudge-fpm.conf
300+
@if [ ! -d "/etc/nginx/" ]; then echo "Couldn't find directory /etc/nginx/. Is nginx installed?"; false; fi
301+
@cmd="ln -sf $(CURDIR)/etc/nginx-conf /etc/nginx/conf.d/domjudge.conf"; \
302+
if [ -d "/etc/nginx/sites-enabled/" ]; then \
303+
cmd="ln -sf $(CURDIR)/etc/nginx-conf /etc/nginx/sites-enabled/domjudge.conf"; \
304+
fi; echo $$cmd; $$cmd
291305
systemctl restart nginx
292-
systemctl restart php$(PHPVERSION)-fpm
306+
@if [ ! -d "$(debpool)" ] && [ ! -d "$(fedpool)" ]; then \
307+
echo "Couldn't find directory $(debpool) or $(fedpool). Is php-fpm installed?"; false; \
308+
fi
309+
@service="php-fpm"; phppool="$(fedpool)"; \
310+
if [ -d "$(debpool)" ]; then \
311+
phppool="$(debpool)"; \
312+
service="php$(PHPVERSION)-fpm"; \
313+
fi; \
314+
service="systemctl restart $$service"; \
315+
ln="ln -sf $(CURDIR)/etc/domjudge-fpm.conf $$phppool/domjudge-fpm.conf"; \
316+
echo $$ln; echo $$service; $$ln; $$service
317+
318+
inplace-postinstall-judgedaemon:
319+
cp $(CURDIR)/etc/sudoers-domjudge /etc/sudoers.d/domjudge
320+
chown root:root /etc/sudoers.d/domjudge
321+
chmod 0600 /etc/sudoers.d/domjudge
293322

294323
# Removes created symlinks; generated logs, submissions, etc. remain in output subdir.
295324
inplace-uninstall-l:

doc/manual/config-advanced.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,11 @@ systemd, then edit the ``domjudge-judgehost.target`` unit file and add
338338
more judgedaemons there.
339339

340340
Although each judgedaemon process will be bound to one single CPU
341-
core, shared use of other resources such as disk I/O might
342-
still have effect on run times.
341+
core, shared use of other resources such as disk I/O typically
342+
still has an effect on run times.
343+
Therefore we recommend running a single judgedaemon per physical
344+
machine for contests where precise timing is important.
345+
343346

344347
Multi-site contests
345348
-------------------

doc/manual/develop.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ already listed under
4343
python3-sphinx python3-sphinx-rtd-theme fontconfig python3-yaml \
4444
latexmk texlive-latex-recommended texlive-latex-extra tex-gyre
4545

46+
For Fedora use::
47+
48+
sudo dnf install git autoconf automake bats \
49+
sphinx-build python3-sphinx_rtd_theme latexmk texlive-cmap \
50+
texlive-metafont texlive-tex-gyre texlive-fncychap texlive-wrapfig \
51+
texlive-capt-of texlive-framed texlive-upquote texlive-needspace \
52+
texlive-tabulary texlive-parskip texlive-oberdiek texlive-makeindex \
53+
texlive-ellipse texlive-pict2e texlive-collection-fontsextra
54+
4655
When this software is present, bootstrapping can be done by running
4756
``make dist``, which creates the ``configure`` script,
4857
downloads and installs the PHP dependencies via composer and

doc/manual/install-judgehost.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ System requirements
1919
* A TCP/IP network which connects the DOMserver and the judgehosts.
2020
The machines only need HTTP(S) access to the DOMserver.
2121

22+
We recommend running a single judgedaemon per physical machine.
23+
For more details see the section :ref:`multiple-judgedaemons`.
2224

2325
.. _judgehost_software:
2426

doc/manual/install-workstation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Command line submit client
1919
DOMjudge comes with a command line submit client which makes it really
2020
convenient for teams to submit their solutions to DOMjudge.
2121

22-
In order to use the submit client, you need Python, the python requests
22+
In order to use the submit client, you need Python, the python requests
2323
library and optionally the python magic library installed on the team's
2424
workstation. To install this on Debian-like distributions::
2525

@@ -85,7 +85,7 @@ the team manual can be generated with the command ``make docs``.
8585
The following should do it on a Debian-like system::
8686

8787
sudo apt install python3-sphinx python3-sphinx-rtd-theme fontconfig python3-yaml
88-
cd <INSTALL_PATH>/doc/
88+
cd <DOWNLOAD_PATH>/doc/
8989
make docs
9090

9191
The resulting manual will then be found in the ``team/`` subdirectory.

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

judge/judgedaemon.main.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,12 @@ function fetch_executable_internal(
626626
$new_judging_run = (array) dj_json_decode(base64_decode(file_get_contents($options['j'])));
627627
$judgeTaskId = $options['t'];
628628

629+
$success = false;
629630
for ($i = 0; $i < 5; $i++) {
631+
if ($i > 0) {
632+
$sleep_ms = 100 + random_int(200, ($i+1)*1000);
633+
dj_sleep(0.001 * $sleep_ms);
634+
}
630635
$response = request(
631636
sprintf('judgehosts/add-judging-run/%s/%s', $new_judging_run['hostname'],
632637
urlencode((string)$judgeTaskId)),
@@ -636,11 +641,13 @@ function fetch_executable_internal(
636641
);
637642
if ($response !== null) {
638643
logmsg(LOG_DEBUG, "Adding judging run result for jt$judgeTaskId successful.");
644+
$success = true;
639645
break;
640646
}
641-
logmsg(LOG_WARNING, "Failed to report $judgeTaskId in attempt #" . ($i + 1) . ".");
642-
$sleep_ms = 100 + random_int(200, ($i+1)*1000);
643-
dj_sleep(0.001 * $sleep_ms);
647+
logmsg(LOG_WARNING, "Failed to report jt$judgeTaskId in attempt #" . ($i + 1) . ".");
648+
}
649+
if (!$success) {
650+
error("Final attempt of uploading jt$judgeTaskId was unsuccessful, giving up.");
644651
}
645652
unlink($options['j']);
646653
exit(0);
@@ -1318,6 +1325,7 @@ function compile(
13181325
function judge(array $judgeTask): bool
13191326
{
13201327
global $EXITCODES, $myhost, $options, $workdirpath, $exitsignalled, $gracefulexitsignalled, $endpointID;
1328+
$startTime = microtime(true);
13211329

13221330
$compile_config = dj_json_decode($judgeTask['compile_config']);
13231331
$run_config = dj_json_decode($judgeTask['run_config']);
@@ -1502,6 +1510,8 @@ function judge(array $judgeTask): bool
15021510

15031511
$new_judging_run = [
15041512
'runresult' => urlencode($result),
1513+
'start_time' => urlencode((string)$startTime),
1514+
'end_time' => urlencode((string)microtime(true)),
15051515
'runtime' => urlencode((string)$runtime),
15061516
'output_run' => rest_encode_file($passdir . '/program.out', $output_storage_limit),
15071517
'output_error' => rest_encode_file($passdir . '/program.err', $output_storage_limit),

0 commit comments

Comments
 (0)