Merge pull request #15769 from nuwang/backport_docker_port_fix

[22.05] backport: fix hostname parsing for newer Docker versions
This commit is contained in:
Martin Cech
2023-03-11 07:15:02 +01:00
committed by GitHub
+6 -1
View File
@@ -198,6 +198,11 @@ def parse_port_text(port_text):
>>> slurm_ports[8888]['host']
'0.0.0.0'
>>> ports = parse_port_text("5432/tcp -> :::5432")
>>> len(ports)
0
>>> ports_new = parse_port_text("5432/tcp -> [::]:5432")
>>> len(ports_new)
0
"""
ports = None
if port_text is not None:
@@ -207,7 +212,7 @@ def parse_port_text(port_text):
raise Exception(f"Cannot parse host and port from line [{line}]")
tool, host = line.split(" -> ", 1)
hostname, port = host.rsplit(":", 1)
if hostname == "::":
if hostname in ["::", "[::]"]:
# Skip unspecified IPv6 address, which is also specified as 0:0:0:0 in another line.
# This is brittle of course, but so is parsing the container ports like this.
continue