@@ -681,21 +681,6 @@ def run(self,
681
681
monitor_function = functools .partial (self .process_monitor )
682
682
self ._execute (runtime , env , runtimeContext , monitor_function )
683
683
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
-
699
684
def docker_monitor (self , cidfile , tmpdir_prefix , cleanup_cidfile , process ):
700
685
# type: (Text, Text, bool, subprocess.Popen) -> None
701
686
"""Record memory usage of the running Docker container."""
@@ -716,7 +701,7 @@ def docker_monitor(self, cidfile, tmpdir_prefix, cleanup_cidfile, process):
716
701
cid = cidhandle .readline ().strip ()
717
702
except (OSError , IOError ):
718
703
cid = None
719
- max_mem = self . docker_get_memory ( cid )
704
+ max_mem = psutil . virtual_memory (). total
720
705
tmp_dir , tmp_prefix = os .path .split (tmpdir_prefix )
721
706
stats_file = tempfile .NamedTemporaryFile (prefix = tmp_prefix , dir = tmp_dir )
722
707
with open (stats_file .name , mode = "w" ) as stats_file_handle :
@@ -736,7 +721,7 @@ def docker_monitor(self, cidfile, tmpdir_prefix, cleanup_cidfile, process):
736
721
except ValueError :
737
722
break
738
723
_logger .info (u"[job %s] Max memory used: %iMiB" , self .name ,
739
- int ((max_mem_percent * max_mem ) / (2 ** 20 )))
724
+ int ((max_mem_percent / 100 * max_mem ) / (2 ** 20 )))
740
725
if cleanup_cidfile :
741
726
os .remove (cidfile )
742
727
0 commit comments