Commit 3ee6f17a authored by Yakubov, Sergey's avatar Yakubov, Sergey Committed by nuwang
Browse files

fix hostname parsing for newer Docker versions

newer versions seem to return "[::]" instead "::",
we check that as well
parent dd2468a6
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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