]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Improve error message when there is no SSH key 1855/head
authorZack Cerza <zack@redhat.com>
Tue, 13 Jun 2023 20:24:12 +0000 (14:24 -0600)
committerZack Cerza <zack@redhat.com>
Tue, 13 Jun 2023 20:31:23 +0000 (14:31 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/orchestra/connection.py

index 1e66e8f87af09e074db3fcc581bd0c16d1ab329f..ebfee2fade7fcbd4d0da051f376a684b56538903 100644 (file)
@@ -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