Skip to content
Snippets Groups Projects
Commit 9f9cb61a authored by Matthias Schnepf's avatar Matthias Schnepf
Browse files

Merge branch 'mhorzela-master-patch-79626' into 'master'

Update docker_wrapper script to set hard memory limit w/o swap

See merge request EKPCondor/HTConfig!11
parents bb45bf90 8afe5aa0
Branches
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@ TRUSTED_IMAGES = [
'unlhcc/osg-wn-el7',
'docker.io/unlhcc/osg-wn-el7',
'mschnepf/slc6-condocker',
'mschnepf/slc7-condocker',
'pkonst/gridka-wn-sl6',
'gitlab-registry.cern.ch/batch-team/slc6-batchwn',
]
......@@ -48,7 +49,7 @@ def main():
cmd = [DOCKER_BIN] + sys.argv[1:]
# Are we handling 'docker run'?
if args.exe == 'run':
if args.exe == 'create':
# Yes, parse the options to 'docker run'
parser = ArgumentParser(add_help=False)
parser.add_argument('exe')
......@@ -59,12 +60,17 @@ def main():
# which are passed from Condor to 'docker run'.
# Otherwise we cannot identify the Docker image because it is a
# positional argument.
parser.add_argument('--cpu-shares', dest='cpu-shares', action='append')
parser.add_argument('--memory', action='append')
parser.add_argument('--cap-drop', dest='cap-drop', action='append')
parser.add_argument('--hostname', action='append')
parser.add_argument('--label', action='append')
parser.add_argument('--name', action='append')
parser.add_argument('--env', '-e', action='append')
parser.add_argument('--volume', action='append')
parser.add_argument('--workdir', action='append')
parser.add_argument('--user', action='append')
parser.add_argument('--group-add', dest='group-add', action='append')
args, docker_opts = parser.parse_known_args()
......@@ -74,8 +80,8 @@ def main():
continue
for val in vals or []:
docker_opts += ['--' + arg, val]
# Replace hard with soft memory limit
docker_opts = [opts.replace('--memory=', '--memory-reservation=') for opts in docker_opts]
if arg=='memory':
docker_opts += ['--memory-swap', val]
# Did we successfully parse the docker run command?
......@@ -84,10 +90,12 @@ def main():
if args.image in TRUSTED_IMAGES:
docker_opts += TRUSTED_CAPABILITIES
# Build the new 'docker run' command
# Build the new 'docker create' command
cmd = [DOCKER_BIN, args.exe] + docker_opts + [args.image] + args.command
else:
pass
syslog.syslog('"%s" => "%s"' % (' '.join(sys.argv), ' '.join(cmd)))
syslog.syslog('"{}" => "{}"'.format(' '.join(sys.argv), ' '.join(cmd)))
ret = subprocess.call(cmd)
sys.exit(ret)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment