Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a configuration file for the judge inside the container. #870

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

osmanirosado
Copy link

Then we can use this command to run the judge

docker run \
  --name judge \
  -v /mnt/dmoj/problems:/problems \
  --cap-add=SYS_PTRACE \
  -d \
  dmoj/judge-tier3:latest \
  run -c /judge.yml $BRIDGE_ADDRESS $JUDGE_NAME $JUDGE_KEY

Some benefits of this command are:

  • No need to extract the contents of the file /judge-runtime-paths.yml outside the container for the configuration of the judge.
  • It is easier to run multiple judges using different values for the variables JUDGE_NAME and JUDGE_KEY.

Then you can use this command: run -c /judge.yml $BRIDGE_ADDRESS $JUDGE_NAME $JUDGE_KEY.
@dmoj-build
Copy link
Collaborator

Can one of the admins verify this patch?

Copy link
Member

@quantum5 quantum5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is easier to run multiple judges using different values for the variables JUDGE_NAME and JUDGE_KEY.

This has always been specified on the command line and I don't see how your changes change this at all

@@ -6,6 +6,8 @@ RUN mkdir /judge /problems && cd /judge && \
pip3 install -e . && \
HOME=~judge . ~judge/.profile && \
runuser -u judge -w PATH -- dmoj-autoconf -V > /judge-runtime-paths.yml && \
echo ' crt_x86_in_lib32: true' >> /judge-runtime-paths.yml
echo ' crt_x86_in_lib32: true' >> /judge-runtime-paths.yml && \
echo 'problem_storage_root: [ "/problems" ]' > /judge.yml && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? We already use /problems for problem storage by default without a configuration file. Your /judge.yml literally reimplements the existing default behaviour.

Copy link
Author

@osmanirosado osmanirosado Aug 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, but when I try to run this command

docker run \
  --name judge \
  -v /mnt/problems:/problems \
  --cap-add=SYS_PTRACE \
  -d \
  dmoj/judge-tier3:latest \
  run $BRIDGE_ADDRESS $JUDGE_NAME $JUDGE_KEY

I get the following error:

Running live judge...
INFO 2021-08-09 12:16:46,462 57 packet Preparing to connect to [10.12.101.21]:9999 as: None
INFO 2021-08-09 12:16:46,462 57 packet TLS not enabled.
INFO 2021-08-09 12:16:46,471 57 packet Opening connection to: [10.12.101.21]:9999
INFO 2021-08-09 12:16:46,474 57 packet Starting handshake with: [10.12.101.21]:9999
INFO 2021-08-09 12:16:46,475 57 packet Awaiting handshake response: [10.12.101.21]:9999
ERROR 2021-08-09 12:16:46,483 57 packet Cannot understand handshake response: [10.12.101.21]:9999
Traceback (most recent call last):
  File "/judge/dmoj/packet.py", line 288, in handshake
    size = PacketManager.SIZE_PACK.unpack(data)[0]
struct.error: unpack requires a buffer of 4 bytes
ERROR 2021-08-09 12:16:46,484 57 packet Authentication as "None" failed on: [10.12.101.21]:9999
WARNING 2021-08-09 12:16:46,484 57 packet Attempting reconnection in 4s: [10.12.101.21]:9999
INFO 2021-08-09 12:16:46,484 57 packet Dropping old connection.

Note that the -c option appears as mandatory in the documentation show by the read me file of the project.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-c is not necessary in docker. Also this looks suspiciously like a shell quoting issue that you managed to work around by using yaml. The real solution is to properly quote your key.

Copy link
Author

@osmanirosado osmanirosado Aug 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The environment variables are quoted now and the command docker-compose config is used to review if the variable interpolation is correct, but the error persists. I share the code here. You can see the logs bellow.

app_1  | Running live judge...
app_1  | INFO 2021-08-10 19:09:58,139 55 packet Preparing to connect to [10.12.101.21]:9999 as: None
app_1  | INFO 2021-08-10 19:09:58,139 55 packet TLS not enabled.
app_1  | INFO 2021-08-10 19:09:58,160 55 packet Opening connection to: [10.12.101.21]:9999
app_1  | INFO 2021-08-10 19:09:58,163 55 packet Starting handshake with: [10.12.101.21]:9999
app_1  | INFO 2021-08-10 19:09:58,165 55 packet Awaiting handshake response: [10.12.101.21]:9999
app_1  | ERROR 2021-08-10 19:09:58,172 55 packet Cannot understand handshake response: [10.12.101.21]:9999
app_1  | Traceback (most recent call last):
app_1  |   File "/judge/dmoj/packet.py", line 288, in handshake
app_1  |     size = PacketManager.SIZE_PACK.unpack(data)[0]
app_1  | struct.error: unpack requires a buffer of 4 bytes
app_1  | ERROR 2021-08-10 19:09:58,173 55 packet Authentication as "None" failed on: [10.12.101.21]:9999
app_1  | WARNING 2021-08-10 19:09:58,173 55 packet Attempting reconnection in 4s: [10.12.101.21]:9999
app_1  | INFO 2021-08-10 19:09:58,173 55 packet Dropping old connection.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is your judge called None? If not, there has to be a variable interpolation issue somewhere, like $JUDGE_NAME somehow being an empty string.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have inserted set -x, before the last command runuser -u judge "${command[@]}" -- "$@" of the entry point script, to see the executed code. I build the image again and set up the judge. This is the result:

Creating network "judge1_default" with the default driver
Creating judge1_app_1 ... done
Attaching to judge1_app_1
app_1  | /home/judge/.profile: line 31: /root/.cargo/env: No such file or directory
app_1  | + runuser -u judge dmoj -- 10.12.101.21 faraday-judge-1 'qE-T^)Ui3~*{AI(j-Qi:n*kC)pd#7dQ8N;Ae6u+U>%s;l)&}?w0@%44^AXuob[:c%lL-#]RB:68e+V!z)X}!sgN@,Mep4ww8zxhN'
app_1  | Self-testing executors
app_1  | Self-testing ADA:    Success [0.003s, 1736 KB]   gnatmake 10.2.1

In the output, we can see the command. The environment variables are correctly interpolated. But I get the same error:

app_1  | Running live judge...
app_1  | INFO 2021-08-11 14:13:14,116 55 packet Preparing to connect to [10.12.101.21]:9999 as: None
app_1  | INFO 2021-08-11 14:13:14,116 55 packet TLS not enabled.
app_1  | INFO 2021-08-11 14:13:14,136 55 packet Opening connection to: [10.12.101.21]:9999
app_1  | INFO 2021-08-11 14:13:14,139 55 packet Starting handshake with: [10.12.101.21]:9999
app_1  | INFO 2021-08-11 14:13:14,141 55 packet Awaiting handshake response: [10.12.101.21]:9999
app_1  | ERROR 2021-08-11 14:13:14,149 55 packet Cannot understand handshake response: [10.12.101.21]:9999

I also note an error before the command execution, the line 31 of .profile script fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants