Skip to content

Commit

Permalink
Build docker run args the same in distDocker
Browse files Browse the repository at this point in the history
Make distDocker's runJob similar to localDocker's. Build a list
of args instead of assembling nested strings. Make sure to preserve
quoting of interior arguments. This has the effect of making the vm core
and memory limits effective for distDocker
  • Loading branch information
cg2v committed Dec 13, 2024
1 parent ce87fcf commit 56cd69e
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 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,7 @@ 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

0 comments on commit 56cd69e

Please sign in to comment.