From: Zack Cerza Date: Wed, 29 Nov 2017 23:25:18 +0000 (-0700) Subject: Tolerate failure to scan VM host keys X-Git-Tag: 1.1.0~376^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=33c874a06db6e640e21b8034b94ee324ed218edc;p=teuthology.git Tolerate failure to scan VM host keys Signed-off-by: Zack Cerza --- diff --git a/teuthology/lock/cli.py b/teuthology/lock/cli.py index 66702d3ae..dfd50ca84 100644 --- a/teuthology/lock/cli.py +++ b/teuthology/lock/cli.py @@ -87,7 +87,7 @@ def main(ctx): vmachines.append(machine['name']) if vmachines: log.info("updating host keys for %s", ' '.join(sorted(vmachines))) - keys.do_update_keys(vmachines) + keys.do_update_keys(vmachines, _raise=False) # get statuses again to refresh any updated keys statuses = query.get_statuses(machines) if statuses: diff --git a/teuthology/lock/keys.py b/teuthology/lock/keys.py index c59bdb719..4aafc26a3 100644 --- a/teuthology/lock/keys.py +++ b/teuthology/lock/keys.py @@ -7,11 +7,11 @@ from . import ops, query log = logging.getLogger(__name__) -def do_update_keys(machines, all_=False): +def do_update_keys(machines, all_=False, _raise=True): reference = query.list_locks(keyed_by_name=True) if all_: machines = reference.keys() - keys_dict = misc.ssh_keyscan(machines) + keys_dict = misc.ssh_keyscan(machines, _raise=_raise) return push_new_keys(keys_dict, reference), keys_dict diff --git a/teuthology/misc.py b/teuthology/misc.py index b1fa3d632..59825bc98 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -1129,11 +1129,12 @@ def get_valgrind_args(testdir, name, preamble, v): return args -def ssh_keyscan(hostnames): +def ssh_keyscan(hostnames, _raise=True): """ Fetch the SSH public key of one or more hosts :param hostnames: A list of hostnames, or a dict keyed by hostname + :param _raise: Whether to raise an exception if not all keys are retrieved :returns: A dict keyed by hostname, with the host keys as values """ if isinstance(hostnames, basestring): @@ -1143,7 +1144,11 @@ def ssh_keyscan(hostnames): keys_dict = dict() for hostname in hostnames: with safe_while( - sleep=1, tries=5, action="ssh_keyscan " + hostname) as proceed: + sleep=1, + tries=5 if _raise else 1, + _raise=_raise, + action="ssh_keyscan " + hostname, + ) as proceed: while proceed(): key = _ssh_keyscan(hostname) if key: @@ -1151,7 +1156,11 @@ def ssh_keyscan(hostnames): break if len(keys_dict) != len(hostnames): missing = set(hostnames) - set(keys_dict.keys()) - raise RuntimeError("Unable to scan these host keys: %s" % missing) + msg = "Unable to scan these host keys: %s" % ' '.join(missing) + if not _raise: + log.warn(msg) + else: + raise RuntimeError(msg) return keys_dict