Fix SSH connectivity issues.

- increase SSH connection attempts number to 60 (5 minutes)
- avoiding using host heys to prevent connection failures

Change-Id: I10babbbd650d9a595b7c5361886da7ad0f3df2a0
This commit is contained in:
Federico Ressi 2019-07-12 21:06:45 +02:00
parent 6cf18ee585
commit b62a2a1122
2 changed files with 4 additions and 4 deletions

View File

@ -292,8 +292,7 @@ def ssh_connect(hostname, username=None, port=None, connection_interval=None,
connection_attempts=None, proxy_command=None,
proxy_client=None, **parameters):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.WarningPolicy())
login = _command.ssh_login(hostname=hostname, username=username, port=port)
attempts = connection_attempts or 1
@ -317,7 +316,8 @@ def ssh_connect(hostname, username=None, port=None, connection_interval=None,
if attempt >= attempts:
raise
LOG.debug("Error logging in to %r: \n(%s)", login, ex)
LOG.debug("Error logging in to %r: \n(%s)", login, ex,
exc_info=1)
sleep_time = start_time + interval - time.time()
if sleep_time > 0.:
LOG.debug("Retrying connecting to %r in %d seconds...", login,

View File

@ -52,7 +52,7 @@ def register_tobiko_options(conf):
default=5.,
help="SSH connect timeout in seconds"),
cfg.IntOpt('connection_attempts',
default=24,
default=60,
help=("Incremental seconds to wait after every "
"failed SSH connection attempt")),
cfg.FloatOpt('connection_interval',