Merge "Handle socket timeout while reconnecting ssh" into stable/newton

This commit is contained in:
Jenkins 2017-02-14 13:32:18 +00:00 committed by Gerrit Code Review
commit aa23a25b6c
1 changed files with 8 additions and 5 deletions

View File

@ -24,7 +24,6 @@ import traceback
from warnings import warn
import devops
from devops.helpers.helpers import wait
from devops.helpers.metaclasses import SingletonMeta
from devops.helpers.ssh_client import SSHClient
from paramiko import RSAKey
@ -142,11 +141,15 @@ class SSHManager(six.with_metaclass(SingletonMeta, object)):
:return:
"""
try:
wait(lambda: remote.execute("cd ~")['exit_code'] == 0, timeout=20)
except Exception:
logger.info('SSHManager: Check for current '
'connection fails. Try to reconnect')
from fuelweb_test.helpers.utils import RunLimit
with RunLimit(
seconds=5,
error_message="Socket timeout! Forcing reconnection"):
remote.check_call("cd ~")
except:
logger.debug(traceback.format_exc())
logger.info('SSHManager: Check for current connection fails. '
'Trying to reconnect')
remote.reconnect()
return remote