diff --git a/vmms/distDocker.py b/vmms/distDocker.py index b6d498e5..12136e2e 100644 --- a/vmms/distDocker.py +++ b/vmms/distDocker.py @@ -271,33 +271,28 @@ def runJob(self, vm, runTimeout, maxOutputFileSize, disableNetwork): self.log.debug("Lost persistent SSH connection") return ret + 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.append(f"--memory={vm.memory}m") + if disableNetwork: + 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" - % ( - config.Config.VM_ULIMIT_USER_PROC, - config.Config.VM_ULIMIT_FILE_SIZE, - runTimeout, - config.Config.MAX_OUTPUT_FILE_SIZE, - ) + f"autodriver -u {config.Config.VM_ULIMIT_USER_PROC} " + f"-f {config.Config.VM_ULIMIT_FILE_SIZE} " + f"-t {runTimeout} -o {config.Config.MAX_OUTPUT_FILE_SIZE} " + "autolab > output/feedback 2>&1" ) - # 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.append( + f"\"cp -r mount/* autolab/; su autolab -c '{autodriverCmd}'; \ + cp output/feedback mount/feedback\"" ) self.log.debug("Running job: %s" % args) @@ -306,7 +301,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, ) diff --git a/vmms/localDocker.py b/vmms/localDocker.py index 45dda03d..c5bf9313 100644 --- a/vmms/localDocker.py +++ b/vmms/localDocker.py @@ -156,31 +156,28 @@ 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.append(f"--memory{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" - % ( - config.Config.VM_ULIMIT_USER_PROC, - config.Config.VM_ULIMIT_FILE_SIZE, - runTimeout, - config.Config.MAX_OUTPUT_FILE_SIZE, - ) + f"autodriver -u {config.Config.VM_ULIMIT_USER_PROC} " + f"-f {config.Config.VM_ULIMIT_FILE_SIZE} " + f"-t {runTimeout} -o {config.Config.MAX_OUTPUT_FILE_SIZE} " + "autolab > output/feedback 2>&1" ) - 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)