]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
misc: allow _ssh_keyscan return None again 1990/head
authorKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Wed, 31 Jul 2024 21:48:09 +0000 (23:48 +0200)
committerKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Wed, 7 Aug 2024 20:32:54 +0000 (22:32 +0200)
A host may not have any keys, so _ssh_keyscan should return None,
instead of failing with error:

    IndexError: list index out of range

Fixes: dbd55e37563ce0fde01e1bfa19ca2fd2c03f0194
Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@clyso.com>
teuthology/misc.py

index c3d324a4bcdad8ac5502baad5d7eebc907eea82a..97521895ac655ba4189cec0d38c02bccd36dba9e 100644 (file)
@@ -1127,7 +1127,8 @@ def _ssh_keyscan(hostname):
     for line in p.stdout:
         host, key = line.strip().decode().split(' ', 1)
         keys.append(key)
-    return sorted(keys)[0]
+    if len(keys) > 0:
+        return sorted(keys)[0]
 
 
 def ssh_keyscan_wait(hostname):