Skip to content

Commit 1e088a9

Browse files
committed
More Docker user sanitizing/fixing
1 parent 9d08a21 commit 1e088a9

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

tests/test_helpers.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@ def _install_WfCommons_on_container(container):
5050
tar_data = _make_tarfile_of_wfcommons()
5151
container.put_archive(target_path, tar_data)
5252
# Cleanup files that came from the host
53-
exit_code, output = container.exec_run("sudo chown -R wfcommons:wfcommons /tmp/WfCommons", user="wfcommons", stdout=True, stderr=True)
54-
exit_code, output = container.exec_run("/bin/rm -rf /tmp/WfCommons/build/", user="wfcommons", stdout=True, stderr=True)
55-
exit_code, output = container.exec_run("/bin/rm -rf /tmp/WfCommons/*.egg-info/", user="wfcommons", stdout=True, stderr=True)
53+
exit_code, output = container.exec_run("sudo /bin/rm -rf /tmp/WfCommons/build/", user="wfcommons", stdout=True, stderr=True)
54+
exit_code, output = container.exec_run("sudo /bin/rm -rf /tmp/WfCommons/*.egg-info/", user="wfcommons", stdout=True, stderr=True)
5655
# Clean up and force a rebuild of cpu-benchmark (because it may be compiled for the wrong architecture)
57-
exit_code, output = container.exec_run("/bin/rm -rf /tmp/WfCommons/bin/cpu-benchmark.o", user="wfcommons", stdout=True,
56+
exit_code, output = container.exec_run("sudo /bin/rm -rf /tmp/WfCommons/bin/cpu-benchmark.o", user="wfcommons", stdout=True,
5857
stderr=True)
59-
exit_code, output = container.exec_run("/bin/rm -rf /tmp/WfCommons/bin/cpu-benchmark", user="wfcommons", stdout=True,
58+
exit_code, output = container.exec_run("sudo /bin/rm -rf /tmp/WfCommons/bin/cpu-benchmark", user="wfcommons", stdout=True,
6059
stderr=True)
6160

6261
# Install WfCommons on the container (to install wfbench and cpu-benchmark really)
@@ -114,12 +113,6 @@ def _start_docker_container(backend, mounted_dir, working_dir, bin_dir, command=
114113
else:
115114
sys.stderr.write(f"[{backend}] Not Copying wfbench and cpu-benchmark...\n")
116115

117-
# Change file permissions
118-
exit_code, output = container.exec_run(["sh", "-c", "sudo chown -R wfcommons:wfcommons ."],
119-
user="wfcommons",
120-
stdout=True, stderr=True)
121-
122-
123116
container.backend = backend
124117
return container
125118

tests/translators_loggers/test_translators_loggers.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,11 @@ def test_translator(self, backend) -> None:
274274
translator.translate(output_folder=dirpath)
275275

276276
# Make the directory that holds the translation world-writable,
277-
# so that docker commands won't fail
278-
# os.chmod(dirpath, 0o777)
277+
# so that we don't have any permission shenanigans
278+
for directory, directory_name, filenames in os.walk(dirpath):
279+
os.chmod(directory, 0o777)
280+
for filename in filenames:
281+
os.chmod(os.path.join(directory, filename), 0o777)
279282

280283
# Start the Docker container
281284
container = _start_docker_container(backend if backend != "nextflow_subworkflow" else "nextflow", str_dirpath, str_dirpath, str_dirpath + "bin/")
@@ -289,6 +292,12 @@ def test_translator(self, backend) -> None:
289292
run_workflow_methods[backend](container, num_tasks, str_dirpath)
290293
sys.stderr.write(f"[{backend}] Workflow ran in %.2f seconds\n" % (time.time() - start_time))
291294

295+
# Make the whole content world-writable/readable
296+
# so that we don't have any permission shenanigans for loggers below
297+
exit_code, output = container.exec_run(cmd=["bash", "-c", "chmod -R 0777 ."],
298+
user="wfcommons",
299+
stdout=True, stderr=True)
300+
292301
# Run the log parser if any
293302
if backend == "pegasus":
294303
parser = PegasusLogsParser(dirpath / "work/wfcommons/pegasus/Blast-Benchmark/run0001/")

0 commit comments

Comments
 (0)