Skip to content

Commit 0798fe3

Browse files
committed
Allow each cmsWorker to use up to 1000 isolate boxes.
Also updates the box range to reflect the new default in isolate.
1 parent 520ab66 commit 0798fe3

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ RUN <<EOF
6363
#!/bin/bash -ex
6464
# Need to set user ID manually: otherwise it'd be 1000 on debian
6565
# and 1001 on ubuntu.
66-
useradd -ms /bin/bash -u 1001 cmsuser
66+
# 1001 is taken by `isolate`.
67+
useradd -ms /bin/bash -u 1002 cmsuser
6768
usermod -aG sudo cmsuser
6869
usermod -aG isolate cmsuser
6970
# Disable sudo password
@@ -79,12 +80,12 @@ COPY --chown=cmsuser:cmsuser install.py constraints.txt /home/cmsuser/src/
7980

8081
WORKDIR /home/cmsuser/src
8182

82-
RUN --mount=type=cache,target=/home/cmsuser/.cache/pip,uid=1001 ./install.py venv
83+
RUN --mount=type=cache,target=/home/cmsuser/.cache/pip,uid=1002 ./install.py venv
8384
ENV PATH="/home/cmsuser/cms/bin:$PATH"
8485

8586
COPY --chown=cmsuser:cmsuser . /home/cmsuser/src
8687

87-
RUN --mount=type=cache,target=/home/cmsuser/.cache/pip,uid=1001 ./install.py cms --devel
88+
RUN --mount=type=cache,target=/home/cmsuser/.cache/pip,uid=1002 ./install.py cms --devel
8889

8990
RUN <<EOF
9091
#!/bin/bash -ex

cms/grading/Sandbox.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -904,18 +904,21 @@ def __init__(self, file_cacher, name=None, temp_dir=None):
904904
"""
905905
SandboxBase.__init__(self, file_cacher, name, temp_dir)
906906

907-
# Isolate only accepts ids between 0 and 999 (by default). We assign
908-
# the range [(shard+1)*10, (shard+2)*10) to each Worker and keep the
909-
# range [0, 10) for other uses (command-line scripts like cmsMake or
910-
# direct console users of isolate). Inside each range ids are assigned
911-
# sequentially, with a wrap-around.
907+
NUM_IDS = 65000
908+
IDS_PER_SHARD = 1000
909+
910+
# Isolate only accepts ids up to 65000. We assign
911+
# the range [(shard+1)*1000, (shard+2)*1000) to each Worker and keep
912+
# the range [0, 1000) for other uses (command-line scripts like cmsMake
913+
# or direct console users of isolate). Inside each range ids are
914+
# assigned sequentially, with a wrap-around.
912915
# FIXME This is the only use of FileCacher.service, and it's an
913916
# improper use! Avoid it!
914917
if file_cacher is not None and file_cacher.service is not None:
915-
box_id = ((file_cacher.service.shard + 1) * 10
916-
+ (IsolateSandbox.next_id % 10)) % 1000
918+
box_id = ((file_cacher.service.shard + 1) * IDS_PER_SHARD
919+
+ (IsolateSandbox.next_id % IDS_PER_SHARD)) % NUM_IDS
917920
else:
918-
box_id = IsolateSandbox.next_id % 10
921+
box_id = IsolateSandbox.next_id % NUM_IDS
919922
IsolateSandbox.next_id += 1
920923

921924
# We create a directory "home" inside the outer temporary directory,

config/cms.sample.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ ResourceService = [["localhost", 28000]]
4040
ScoringService = [["localhost", 28500]]
4141
Checker = [["localhost", 22000]]
4242
EvaluationService = [["localhost", 25000]]
43+
44+
# NOTE: more than 64 workers on the same machine are not supported.
4345
Worker = [
4446
["localhost", 26000],
4547
["localhost", 26001],

0 commit comments

Comments
 (0)