Retry ssh connections on auth failure.
Some cloud instance types (Fedora for example) create the ssh user after sshd comes online. This allows our ssh connection retry loop to handle this scenario gracefully. Change-Id: Ie345dea50fc2983112cd2e72826a708583d2712a
This commit is contained in:
parent
2d45897802
commit
1963731f7d
|
@ -23,6 +23,7 @@ import logging
|
|||
from sshclient import SSHClient
|
||||
|
||||
import fakeprovider
|
||||
import paramiko
|
||||
|
||||
log = logging.getLogger("nodepool.utils")
|
||||
|
||||
|
@ -46,6 +47,10 @@ def ssh_connect(ip, username, connect_kwargs={}, timeout=60):
|
|||
try:
|
||||
client = SSHClient(ip, username, **connect_kwargs)
|
||||
break
|
||||
except paramiko.AuthenticationException, e:
|
||||
# This covers the case where the cloud user is created
|
||||
# after sshd is up (Fedora for example)
|
||||
log.info('Password auth exception. Try number %i...' % count)
|
||||
except socket.error, e:
|
||||
if e[0] not in [errno.ECONNREFUSED, errno.EHOSTUNREACH]:
|
||||
log.exception('Exception while testing ssh access:')
|
||||
|
|
Loading…
Reference in New Issue