pytest-docker-tools icon indicating copy to clipboard operation
pytest-docker-tools copied to clipboard

Race in container.ready

Open Jc2k opened this issue 3 years ago • 1 comments

PDB session

(Pdb) p self.ports.values()
[[]]
(Pdb) self.reload()
(Pdb) p self.ports.values()
[[51350]]

Maybe something like this?

        # If a user has exposed a port then wait for LISTEN socket to show up in netstat
        ports = self._container.attrs["NetworkSettings"]["Ports"]
        for port, listeners in ports.items():
            if not listeners:
                continue

 ++           if port not in self.ports:
 ++               return False

            port, proto = port.split("/")

            assert proto in ("tcp", "udp")

            if proto == "tcp" and port not in self.get_open_tcp_ports():
                return False

            if proto == "udp" and port not in self.get_open_udp_ports():
                return False

Jc2k avatar Feb 21 '22 21:02 Jc2k

First time seen it in 1000's of tests, so unlikely to repro outside of a unittest.

Jc2k avatar Feb 21 '22 21:02 Jc2k