DOMjudge / domjudge-packaging

DOMjudge packaging for (Linux) distributions and live image
32 stars 40 forks source link

Docker: JMS serializer cache dir not writable #32

Closed RafaelPaulovic closed 5 years ago

RafaelPaulovic commented 5 years ago

Hi, I've been trying to deploy the DOMjudge docker images for a while now.

I always run the commands in the README.md file, Change the password on the system for the judgehost. Now the variants that I have are:

When I use the version 5.3.3 or below I manage to have access for the API using the normal link: http://localhost:12345/api/

If I run any other version above it what I get is the known: error 500 "Internal Server Error"

In any of the versions when I run the Judgehost Image what I get if I change the DOMSERVER_BASEURL environment variable from http://domserver to http://localhost:12345/ is: For the version 6.0.3:

Registering judgehost on endpoint http://localhost:12345/api/v4
[Mar 20 14:00:13.270] judgedaemon[41]: error: Error while executing curl POST to url http://localhost:12345/api/v4/judgehosts: Failed to connect to localhost port 12345: Connection refused

And the version 5.3.3:

[Mar 20 14:43:49.920] judgedaemon[41]: Judge started on judgedaemon-0-0 [DOMjudge/5.3.3]
[Mar 20 14:43:49.937] judgedaemon[41]: Registering judgehost on endpoint http://localhost:12345/api
[Mar 20 14:43:49.989] judgedaemon[41]: error: Error while executing curl POST to url http://localhost:12345/api/judgehosts: Failed to connect to localhost port 12345: Connection refused

And if I don't change the DOMSERVER_BASEURL, meaning trying to connect the Judgehost in the wrong URL of the DOMSERVER what I get is that actually the new instance of the Judgehost connects to the system and waits for the new submitions. The terminal keeps in this position:

For the version 6.0.3

[Mar 20 14:01:09.212] judgedaemon[41]: Judge started on judgedaemon-0-0 [DOMjudge/6.0.3]
[Mar 20 14:01:09.221] judgedaemon[41]: Registering judgehost on endpoint http://domserver/api/v4
[Mar 20 14:01:09.703] judgedaemon[41]: No submissions in queue (for endpoint default), waiting...
[Mar 20 14:41:19.304] judgedaemon[41]: Judge started on judgedaemon-0-0 [DOMjudge/5.3.3]
[Mar 20 14:41:19.310] judgedaemon[41]: Registering judgehost on endpoint http://domserver/api
[Mar 20 14:41:19.589] judgedaemon[41]: No submissions in queue (for endpoint default), waiting...

Being the only difference the API version from v3 to v4.

And if I send a submission using the web application I actually receives in the console of the Judgehost at this second case when it is connected to the wrong URL of the server.

[Mar 20 14:56:18.196] judgedaemon[41]: Working directory: /opt/domjudge/judgehost/judgings/judgedaemon-0-0/endpoint-default/c2-s1-j1
[Mar 20 14:56:18.312] judgedaemon[41]: Fetching new executable 'c'
[Mar 20 14:56:19.432] judgedaemon[41]: executing chroot script: 'chroot-startstop.sh start'
[Mar 20 14:56:20.081] judgedaemon[41]: Fetched new input,output testcase 1 for problem p1
[Mar 20 14:56:20.089] judgedaemon[41]: Fetching new executable 'compare'
[Mar 20 14:56:21.207] judgedaemon[41]: Fetching new executable 'run'
[Mar 20 14:56:22.059] judgedaemon[41]: executing chroot script: 'chroot-startstop.sh stop'
[Mar 20 14:56:22.399] judgedaemon[41]: Judging s1/j1 finished

So I would like to know if my Judgehost is connected to the right Server and if it's possible for me to run a newer version with access to the API.

Currently I'm running all these docker images in a Linux VM inside the VMware Workstation software.

Would appreciate if someone could help me. Thanks.

nickygerritsen commented 5 years ago

Hi!

If I run any other version above it what I get is the known: error 500 "Internal Server Error"

Can you check the webapp/var/log/prod.log file inside the domserver Docker container to see what it says?

In any of the versions when I run the Judgehost Image what I get if I change the DOMSERVER_BASEURL environment variable from http://domserver to http://localhost:12345/ is:

The judgehost Docker container can not access localhost:12345. By running the docker command with --link domserver:domserver you linked the containers together, so that is why it could access it using http://domserver/ .

to the system and waits for the new submitions. The terminal keeps in this position:

This is what it should do indeed.

And if I send a submission using the web application I actually receives in the console of the Judgehost at this second case when it is connected to the wrong URL of the server.

This is also correct. Why do you think the URL is wrong, because it should be correct if you run the judgehost container with --link domserver:domserver.

So I would like to know if my Judgehost is connected to the right Server and if it's possible for me to run a newer version with access to the API.

If you see the submission in the web interface as being judged, all is working correctly. Of course if you want to access the API yourself (using your browser, some tool or cURL or something), then you need to use http://localhost:12345/, because your script/tool is running from your local machine and not from inside Docker.

I hope this makes sense. If so, can you close the issue? If not, let me know and I'll try to help.

RafaelPaulovic commented 5 years ago

Yes it makes perfect sense. I will try to fix everything and confirm it for you if it works in a second.

Thank you.

RafaelPaulovic commented 5 years ago

So, I executed all the images for the 6.0.3 version.

Entered the bash of the Domserver, in the path: /opt/domjudge/domserver/webapp/var/logs# The file prod.log doesn't exists. Am I looking in the right place?

From what I understood it's normal that I can't execute files outside the docker. But if I want to access the API from outside, I should change what exactly?

Change the run command line of the judgehost from --link domserver:domserver to --link domserver:localhost or the script tool?

Thank you again.

nickygerritsen commented 5 years ago

Entered the bash of the Domserver, in the path: /opt/domjudge/domserver/webapp/var/logs# The file prod.log doesn't exists. Am I looking in the right place?

Hmmmm that seems like it didn't generate something. Can you run docker exec -it domserver nginx-access-log to see if that produces anything? Open that command and then refresh the page.

From what I understood it's normal that I can't execute files outside the docker. But if I want to access the API from outside, I should change what exactly?

You should change nothing, but just use http://localhost:12345/api (after the above error is fixed).

RafaelPaulovic commented 5 years ago
i507794@master-node:~$ sudo docker exec -it domserver nginx-access-log
==> Press Ctrl-C to exit <==

Yes, it is empty.

nickygerritsen commented 5 years ago

Also after refreshing the http://localhost:12345/api page? Can you also check nginx-error-log?

RafaelPaulovic commented 5 years ago

Also after refreshing the page. Both are empty.

nickygerritsen commented 5 years ago

Could you post here:

RafaelPaulovic commented 5 years ago

For MariaDB: sudo docker run -it --name dj-mariadb -e MYSQL_ROOT_PASSWORD=rootpw -e MYSQL_USER=domjudge -e MYSQL_PASSWORD=djpw -e MYSQL_DATABASE=domjudge -p 13306:3306 mariadb --max-connections=1000

Last 3 lines in the MariaDB terminal:

2019-03-20 14:15:08 0 [Note] mysqld: ready for connections.
Version: '10.3.13-MariaDB-1:10.3.13+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
2019-03-20 14:15:21 13 [Warning] 'proxies_priv' entry '@% root@4f30744087eb' ignored in --skip-name-resolve mode.

For domserver: sudo docker run --link dj-mariadb:mariadb -it -e MYSQL_HOST=mariadb -e MYSQL_USER=domjudge -e MYSQL_DATABASE=domjudge -e MYSQL_PASSWORD=djpw -e MYSQL_ROOT_PASSWORD=rootpw -p 12345:80 --name domserver domjudge/domserver:6.0.3 Last 10 lines in the domserver terminal:


2019-03-20 15:15:27,305 CRIT Supervisor running as root (no user in config file)
2019-03-20 15:15:27,306 INFO Included extra file "/etc/supervisor/conf.d/nginx.conf" during parsing
2019-03-20 15:15:27,306 INFO Included extra file "/etc/supervisor/conf.d/php.conf" during parsing
2019-03-20 15:15:27,331 INFO RPC interface 'supervisor' initialized
2019-03-20 15:15:27,334 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2019-03-20 15:15:27,335 INFO supervisord started with pid 1
2019-03-20 15:15:28,339 INFO spawned: 'nginx' with pid 70
2019-03-20 15:15:28,352 INFO spawned: 'php' with pid 71
2019-03-20 15:15:29,499 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-03-20 15:15:29,501 INFO success: php entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

For judgehost: sudo docker run -it --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro --name judgehost-0 --link domserver:domserver --hostname judgedaemon-0 -e DAEMON_ID=0 domjudge/judgehost:6.0.3

Last 3 lines in judgehost:

[Mar 20 15:31:36.006] judgedaemon[41]: Judge started on judgedaemon-0-0 [DOMjudge/6.0.3]
[Mar 20 15:31:36.010] judgedaemon[41]: Registering judgehost on endpoint http://domserver/api/v4
[Mar 20 15:31:36.483] judgedaemon[41]: No submissions in queue (for endpoint default), waiting...

image

nickygerritsen commented 5 years ago

OK I am getting the same error. This will fix it, for now:

docker exec domserver chown -R www-data: /opt/domjudge/domserver/webapp/var/cache

I will make sure to fix this in the Docker image later.

nickygerritsen commented 5 years ago

To add for others: the JMS serializer cache directory is not writable, because currently it is owned by root. Probably we need to clear the cache as www-data instead of root to fix this.

RafaelPaulovic commented 5 years ago

Thank you for your help, everything is working fine now. :)

nickygerritsen commented 5 years ago

I have just pushed a new domserver Docker image for 6.0.3 with the above fix :)