]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
misc._ssh_keyscan: Sort keys before returning any 1888/head
authorZack Cerza <zack@redhat.com>
Tue, 5 Sep 2023 18:42:46 +0000 (12:42 -0600)
committerZack Cerza <zack@redhat.com>
Tue, 5 Sep 2023 18:42:46 +0000 (12:42 -0600)
ssh-keyscan's output is unsorted, so this function wasn't deterministic.

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/misc.py

index 76a21815d04a61f708365993df62e725ab04dcc4..c03be7e8568bc29157fc4ddd01b73b5fe5191d13 100644 (file)
@@ -1138,9 +1138,11 @@ def _ssh_keyscan(hostname):
         line = line.strip()
         if line and not line.startswith('#'):
             log.error(line)
+    keys = list()
     for line in p.stdout:
         host, key = line.strip().decode().split(' ', 1)
-        return key
+        keys.append(key)
+    return sorted(keys)[0]
 
 
 def ssh_keyscan_wait(hostname):