From 5cdac0498e229ac97201ffbec3690007d3241dd1 Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Wed, 31 Jul 2024 23:48:09 +0200 Subject: [PATCH] misc: allow _ssh_keyscan return None again 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 --- teuthology/misc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index c3d324a4b..97521895a 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -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):