Skip to content
This repository was archived by the owner on May 6, 2024. It is now read-only.

Commit c5cb651

Browse files
Temporary volumes are set to be unique to configuration files (and the run_id)
1 parent de88422 commit c5cb651

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

vantage/node/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,10 @@ def __start_task(self, taskresult):
346346
else:
347347
database_uri = self.config['databases']["default"]
348348

349-
# create a temporary volume for each run_id (tmp_{run_id})
350-
self.__docker.create_temporary_volume(task["run_id"])
351-
# self.__docker.client.containers.get(self.ctx.docker_container_name)
352-
349+
# create a temporary volume for each run_id
350+
vol_name = self.ctx.docker_temporary_volume_name(task["run_id"])
351+
self.__docker.create_volume(vol_name)
352+
353353
# start docker container in the background
354354
if type(taskresult['input']) == dict:
355355
taskresult['input'] = json.dumps(taskresult['input'])
@@ -358,7 +358,7 @@ def __start_task(self, taskresult):
358358
image=task["image"],
359359
database_uri=database_uri,
360360
docker_input=taskresult['input'],
361-
run_id=task["run_id"],
361+
tmp_vol_name=vol_name,
362362
token=token
363363
)
364364

vantage/node/docker_manager.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def create_isolated_network(self, name: str) \
9191

9292
return network
9393

94-
def create_temporary_volume(self, run_id: int):
94+
def create_volume(self, volume_name: str):
9595
""" Create a temporary volume for a single run.
9696
9797
A single run can consist of multiple algorithm containers.
@@ -100,7 +100,6 @@ def create_temporary_volume(self, run_id: int):
100100
101101
:param run_id: integer representing the run_id
102102
"""
103-
volume_name = f"tmp_{run_id}"
104103
try:
105104
self.client.volumes.get(volume_name)
106105
self.log.debug(f"Volume {volume_name} already exists.")
@@ -109,7 +108,7 @@ def create_temporary_volume(self, run_id: int):
109108
self.client.volumes.create(volume_name)
110109

111110
def run(self, result_id: int, image: str, database_uri: str,
112-
docker_input: str, run_id: int, token: str) -> bool:
111+
docker_input: str, tmp_vol_name: int, token: str) -> bool:
113112
""" Runs the docker-image in detached mode.
114113
115114
It will will attach all mounts (input, output and datafile)
@@ -158,7 +157,7 @@ def run(self, result_id: int, image: str, database_uri: str,
158157
# define enviroment variables for the docker-container, the
159158
# host, port and api_path are from the local proxy server to
160159
# facilitate indirect communication with the central server
161-
tmp_folder = "/mnt/tmp"
160+
tmp_folder = "/mnt/tmp" # docker env
162161
environment_variables = {
163162
"INPUT_FILE": str(io_path / "input.txt"),
164163
"OUTPUT_FILE": str(io_path / "output.txt"),
@@ -180,7 +179,7 @@ def run(self, result_id: int, image: str, database_uri: str,
180179
environment=environment_variables,
181180
network=self.isolated_network.name,
182181
volumes={
183-
f"tmp_{run_id}":{
182+
tmp_vol_name:{
184183
"bind":tmp_folder,
185184
"mode": "rw"
186185
},

vantage/util/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ def setup_logging(self):
115115
log.info("Succesfully loaded configuration from '%s'" % self.config_file)
116116
log.info("Logging to '%s'" % self.log_file)
117117
self.log = log
118+
119+
def docker_temporary_volume_name(self, run_id):
120+
return (
121+
f"{constants.APPNAME}-{self.name}-{self.scope}"
122+
f"-{run_id}-tmpvol"
123+
)
118124

119125
@property
120126
def docker_container_name(self):

0 commit comments

Comments
 (0)