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

Change how docker run args are built #267

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions vmms/distDocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,24 +280,20 @@ def runJob(self, vm, runTimeout, maxOutputFileSize, disableNetwork):
config.Config.MAX_OUTPUT_FILE_SIZE,
)
)

# IMPORTANT: The single and double quotes are important, since we
# are switching to the autolab user and then running
# bash commands.
setupCmd = (
'cp -r mount/* autolab/; su autolab -c "%s"; \
cp output/feedback mount/feedback'
% autodriverCmd
)

disableNetworkArg = "--network none" if disableNetwork else ""

args = "(docker run --name %s -v %s:/home/mount %s %s sh -c '%s')" % (
instanceName,
volumePath,
disableNetworkArg,
vm.image,
setupCmd,
args = ["docker", "run", "--name", instanceName, "-v"]
args.append("%s:%s" % (volumePath, "/home/mount"))
if vm.cores:
args.append(f"--cpus={vm.cores}")
if vm.memory:
args.extend(("-m", f"{vm.memory}m"))
if disableNetwork:
args.append("--network", "none")

args.append(vm.image)
args.extend(("sh", "-c"))
args.append(
f"\"cp -r mount/* autolab/; su autolab -c '{autodriverCmd}'; \
cp output/feedback mount/feedback\""
)

self.log.debug("Running job: %s" % args)
Expand All @@ -306,7 +302,8 @@ def runJob(self, vm, runTimeout, maxOutputFileSize, disableNetwork):
["ssh"]
+ DistDocker._SSH_FLAGS
+ vm.ssh_flags
+ ["%s@%s" % (self.hostUser, vm.domain_name), args],
+ ["%s@%s" % (self.hostUser, vm.domain_name)]
+ args,
runTimeout * 2,
)

Expand Down
16 changes: 8 additions & 8 deletions vmms/localDocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ def runJob(self, vm, runTimeout, maxOutputFileSize, disableNetwork):
os.getenv("DOCKER_TANGO_HOST_VOLUME_PATH"), instanceName
)
args = ["docker", "run", "--name", instanceName, "-v"]
args = args + ["%s:%s" % (volumePath, "/home/mount")]
args.append("%s:%s" % (volumePath, "/home/mount"))
if vm.cores:
args = args + [f"--cpus={vm.cores}"]
args.append(f"--cpus={vm.cores}")
if vm.memory:
args = args + ["-m", f"{vm.memory}m"]
args.extend(("-m", f"{vm.memory}m"))
if disableNetwork:
args = args + ["--network", "none"]
args = args + [vm.image]
args = args + ["sh", "-c"]
args.append("--network", "none")
args.append(vm.image)
args.extend(("sh", "-c"))

autodriverCmd = (
"autodriver -u %d -f %d -t %d -o %d autolab > output/feedback 2>&1"
Expand All @@ -176,11 +176,11 @@ def runJob(self, vm, runTimeout, maxOutputFileSize, disableNetwork):
)
)

args = args + [
args.append(
'cp -r mount/* autolab/; su autolab -c "%s"; \
cp output/feedback mount/feedback'
% autodriverCmd
]
)

self.log.debug("Running job: %s" % str(args))
ret = timeout(args, runTimeout * 2)
Expand Down
Loading