Skip to content

Commit 2a5ce6b

Browse files
committed
Remove docker_get_memory
Docker HostConfig.Memory is 0 if no memory limit is set. Use psutil instead.
1 parent b9e9836 commit 2a5ce6b

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

cwltool/job.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -681,21 +681,6 @@ def run(self,
681681
monitor_function = functools.partial(self.process_monitor)
682682
self._execute(runtime, env, runtimeContext, monitor_function)
683683

684-
@staticmethod
685-
def docker_get_memory(cid): # type: (Text) -> int
686-
memory = None
687-
try:
688-
memory = subprocess.check_output(
689-
['docker', 'inspect', '--type', 'container', '--format',
690-
'{{.HostConfig.Memory}}', cid], stderr=subprocess.DEVNULL) # type: ignore
691-
except subprocess.CalledProcessError:
692-
pass
693-
if memory:
694-
value = int(memory)
695-
if value != 0:
696-
return value
697-
return psutil.virtual_memory().total
698-
699684
def docker_monitor(self, cidfile, tmpdir_prefix, cleanup_cidfile, process):
700685
# type: (Text, Text, bool, subprocess.Popen) -> None
701686
"""Record memory usage of the running Docker container."""
@@ -716,7 +701,7 @@ def docker_monitor(self, cidfile, tmpdir_prefix, cleanup_cidfile, process):
716701
cid = cidhandle.readline().strip()
717702
except (OSError, IOError):
718703
cid = None
719-
max_mem = self.docker_get_memory(cid)
704+
max_mem = psutil.virtual_memory().total
720705
tmp_dir, tmp_prefix = os.path.split(tmpdir_prefix)
721706
stats_file = tempfile.NamedTemporaryFile(prefix=tmp_prefix, dir=tmp_dir)
722707
with open(stats_file.name, mode="w") as stats_file_handle:

0 commit comments

Comments
 (0)