Merge pull request #8901 from jmchilton/revert_ip_adjustments

[19.09] Revert hacking IPs in container monitor script.
This commit is contained in:
John Chilton
2019-11-07 10:59:09 -05:00
committed by GitHub
2 changed files with 15 additions and 4 deletions
+6
View File
@@ -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 = {}
+9 -4
View File
@@ -41,12 +41,17 @@ def main():
try:
ports_raw = parse_ports(container_name, connection_configuration)
if ports_raw is not None:
host_ip = socket.gethostbyname(socket.gethostname())
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:
# Override the IPs
ports = docker_util.parse_port_text(ports_raw)
for key in ports:
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: