Add timeout for ssh negotiation on keyscan

We had a launch thread stuck here:

Thread: NodeLauncher-0000341123 (140201917658880)
  File "/usr/lib/python3.5/threading.py", line 882, in _bootstrap
    self._bootstrap_inner()
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.5/dist-packages/nodepool/driver/openstack/handler.py", line 245, in run
    self._run()
  File "/usr/local/lib/python3.5/dist-packages/nodepool/driver/openstack/handler.py", line 216, in _run
    self._launchNode()
  File "/usr/local/lib/python3.5/dist-packages/nodepool/driver/openstack/handler.py", line 201, in _launchNode
    interface_ip, timeout=self._provider.boot_timeout)
  File "/usr/local/lib/python3.5/dist-packages/nodepool/nodeutils.py", line 74, in keyscan
    t.start_client()
  File "/usr/local/lib/python3.5/dist-packages/paramiko/transport.py", line 489, in start_client
    event.wait(0.1)
  File "/usr/lib/python3.5/threading.py", line 549, in wait
    signaled = self._cond.wait(timeout)
  File "/usr/lib/python3.5/threading.py", line 297, in wait
    gotit = waiter.acquire(True, timeout)

This adds a timeout to that method so paramiko won't get stuck there.

Change-Id: I038d88cb141f57b93d8572c067e714f4a3af9c2d
This commit is contained in:
James E. Blair 2017-10-20 13:41:11 -07:00 committed by David Shrewsbury
parent 7e71dc7481
commit 559b01cfa0
1 changed files with 1 additions and 1 deletions

View File

@ -71,7 +71,7 @@ def keyscan(ip, port=22, timeout=60):
sock.settimeout(timeout)
sock.connect(sockaddr)
t = paramiko.transport.Transport(sock)
t.start_client()
t.start_client(timeout=timeout)
key = t.get_remote_server_key()
break
except socket.error as e: