[TRAIN-and-older] Properly close sockets

Currently we properly close the ipv4 socket when we're check for nodes
to become available. This change adds additional closes to ensure we
clean up the sockets when we're done with them while we wait.

Note this code was removed in Ussuri so this is a <= train only patch

Change-Id: Ie1711972e2fdb2af80b50a2bf514fc46151ae4f3
Closes-Bug: #1888676
This commit is contained in:
Alex Schultz 2020-07-23 08:04:42 -06:00
parent 037dd3342f
commit 9e08f1ead2
1 changed files with 3 additions and 1 deletions

View File

@ -178,12 +178,14 @@ def wait_for_ssh_port(host, timeout=ENABLE_SSH_ADMIN_SSH_PORT_TIMEOUT):
return
except socket.error:
try:
# close previous socket before creating a new one
sock.close()
sock = socket.socket(socket.AF_INET6)
sock.connect((host, 22))
sock.close()
return
except socket.error:
pass
sock.close()
time.sleep(1)