From: Zack Cerza Date: Tue, 13 Jun 2023 20:24:12 +0000 (-0600) Subject: Improve error message when there is no SSH key X-Git-Tag: 1.2.0~98^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1855%2Fhead;p=teuthology.git Improve error message when there is no SSH key Signed-off-by: Zack Cerza --- diff --git a/teuthology/orchestra/connection.py b/teuthology/orchestra/connection.py index 1e66e8f87..ebfee2fad 100644 --- a/teuthology/orchestra/connection.py +++ b/teuthology/orchestra/connection.py @@ -96,16 +96,23 @@ def connect(user_at_host, host_key=None, keep_alive=False, timeout=60, log.debug(connect_args) - if not retry: - ssh.connect(**connect_args) - else: - # Retries are implemented using safe_while - with safe_while(sleep=1, action='connect to ' + host) as proceed: - while proceed(): - try: + try: + if not retry: + ssh.connect(**connect_args) + else: + # Retries are implemented using safe_while + with safe_while(sleep=1, action='connect to ' + host) as proceed: + while proceed(): ssh.connect(**connect_args) break - except paramiko.AuthenticationException as e: - log.error(f"Error authenticating with {host}: {str(e)}") + except paramiko.AuthenticationException as e: + log.error(f"Error authenticating with {host}: {str(e)}") + except paramiko.SSHException: + msg = f"Error authenticating with {host}" + if not key_filename: + log.error(msg + ": No SSH private key found!") + raise + else: + log.exception(msg) ssh.get_transport().set_keepalive(keep_alive) return ssh