From 352e751927cd6e8e521db383cbd21f50a51c1b74 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Tue, 29 Oct 2019 10:12:38 -0400 Subject: [PATCH 1/4] Revert hacking IPs in container monitor script. It breaks the Mac setup and seems just wrong, docker might not be on localhost. This needs to be made more specific in some way and should handle those socker commands not working on OS X. --- lib/galaxy_ext/container_monitor/monitor.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/galaxy_ext/container_monitor/monitor.py b/lib/galaxy_ext/container_monitor/monitor.py index e03cda18b9e..df2b13b8118 100644 --- a/lib/galaxy_ext/container_monitor/monitor.py +++ b/lib/galaxy_ext/container_monitor/monitor.py @@ -41,12 +41,8 @@ def main(): try: ports_raw = parse_ports(container_name, connection_configuration) if ports_raw is not None: - host_ip = socket.gethostbyname(socket.gethostname()) with open("container_runtime.json", "w") as f: - # Override the IPs ports = docker_util.parse_port_text(ports_raw) - for key in ports: - ports[key]['host'] = host_ip json.dump(ports, f) break else: From ff08885c2ea0215430c86b7377c1d1bf291e51f3 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 30 Oct 2019 11:03:20 -0400 Subject: [PATCH 2/4] Only re-map container monitor host if can find IP and have 0.0.0.0. --- lib/galaxy_ext/container_monitor/monitor.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/galaxy_ext/container_monitor/monitor.py b/lib/galaxy_ext/container_monitor/monitor.py index df2b13b8118..a64cb75d7d6 100644 --- a/lib/galaxy_ext/container_monitor/monitor.py +++ b/lib/galaxy_ext/container_monitor/monitor.py @@ -41,8 +41,16 @@ def main(): try: ports_raw = parse_ports(container_name, connection_configuration) if ports_raw is not None: + try: + host_ip = socket.gethostbyname(socket.gethostname()) + except Exception: + # doesn't work on OS X + host_ip = None with open("container_runtime.json", "w") as f: ports = docker_util.parse_port_text(ports_raw) + for key in ports: + if ports[key]['host'] == '0.0.0.0' and host_ip is not None: + ports[key]['host'] = host_ip json.dump(ports, f) break else: From 391381d3c40b16c7b9fdbadd9fa8f1f215cb7a59 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 30 Oct 2019 11:08:27 -0400 Subject: [PATCH 3/4] small doctest for docker port parsing --- lib/galaxy/tool_util/deps/docker_util.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/galaxy/tool_util/deps/docker_util.py b/lib/galaxy/tool_util/deps/docker_util.py index e5ef9cb7587..12432c9bbba 100644 --- a/lib/galaxy/tool_util/deps/docker_util.py +++ b/lib/galaxy/tool_util/deps/docker_util.py @@ -225,6 +225,12 @@ def _docker_prefix( def parse_port_text(port_text): + """ + + >>> slurm_ports = parse_port_text("8888/tcp -> 0.0.0.0:32769") + >>> slurm_ports[8888]['host'] + '0.0.0.0' + """ ports = None if port_text is not None: ports = {} From 1663c9e331ee2445ce86a2bca1a6cbd19dae64e1 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Wed, 30 Oct 2019 15:30:03 +0000 Subject: [PATCH 4/4] Check `host_ip` only once --- lib/galaxy_ext/container_monitor/monitor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/galaxy_ext/container_monitor/monitor.py b/lib/galaxy_ext/container_monitor/monitor.py index a64cb75d7d6..b1e1447f1e0 100644 --- a/lib/galaxy_ext/container_monitor/monitor.py +++ b/lib/galaxy_ext/container_monitor/monitor.py @@ -48,9 +48,10 @@ def main(): host_ip = None with open("container_runtime.json", "w") as f: ports = docker_util.parse_port_text(ports_raw) - for key in ports: - if ports[key]['host'] == '0.0.0.0' and host_ip is not None: - ports[key]['host'] = host_ip + if host_ip is not None: + for key in ports: + if ports[key]['host'] == '0.0.0.0': + ports[key]['host'] = host_ip json.dump(ports, f) break else: