Retry SSHExceptions in nodepool

Today, when SSHExceptions are raise, nodepool will abort communication
with the node. Now, nodepool will properly trap them and try again
until the SSH timeout has been raised.

This help with potential race conditions with openssh-server and
nodepool, where nodes would restart sshd after nodepool has
established a connection.

Change-Id: I40bfa1b1af6e4e75f8f14c597c28407ed08023de
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2016-10-05 12:11:47 -04:00
parent 7e3a620fa9
commit aebd030a32
No known key found for this signature in database
GPG Key ID: 611A80832067AF38
1 changed files with 5 additions and 0 deletions

View File

@ -54,6 +54,11 @@ def ssh_connect(ip, username, connect_kwargs={}, timeout=60):
try:
client = SSHClient(ip, username, **connect_kwargs)
break
except paramiko.SSHException as e:
# NOTE(pabelanger): Currently paramiko only returns a string with
# error code. If we want finer granularity we'll need to regex the
# string.
log.exception('Failed to negotiate SSH: %s' % (e))
except paramiko.AuthenticationException as e:
# This covers the case where the cloud user is created
# after sshd is up (Fedora for example)