log progress of wait_for_open_ports

To know what to focus on when some check fail. E.g. to detect that
IPv6 address or its resolution for localhost is misconfigured.

https://pagure.io/freeipa/issue/7083

Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
This commit is contained in:
Petr Vobornik 2017-08-03 16:03:29 +02:00 committed by Tomas Krizek
parent cc72db67e2
commit 038d192065
No known key found for this signature in database
GPG Key ID: 22A2A94B5E49415A

View File

@ -1224,15 +1224,20 @@ def wait_for_open_ports(host, ports, timeout=0):
op_timeout = time.time() + timeout op_timeout = time.time() + timeout
for port in ports: for port in ports:
logger.debug('waiting for port: %s', port)
log_error = True
while True: while True:
port_open = host_port_open(host, port) port_open = host_port_open(host, port, log_errors=log_error)
log_error = False # Log only first err so that the log is readable
if port_open: if port_open:
logger.debug('SUCCESS: port: %s', port)
break break
if timeout and time.time() > op_timeout: # timeout exceeded if timeout and time.time() > op_timeout: # timeout exceeded
raise socket.timeout("Timeout exceeded") raise socket.timeout("Timeout exceeded")
time.sleep(1) time.sleep(1)
def wait_for_open_socket(socket_name, timeout=0): def wait_for_open_socket(socket_name, timeout=0):
""" """
Wait until the specified socket on the local host is open. Timeout Wait until the specified socket on the local host is open. Timeout