From: Sage Weil Date: Sat, 14 Mar 2020 15:07:34 +0000 (-0500) Subject: mgr/cephadm: fix host connection exception X-Git-Tag: v15.2.0~48^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=23514a5529f4e7aca8f51c55c7895b76fca87551;p=ceph.git mgr/cephadm: fix host connection exception 1- catch exception thrown by _get_connection itself 2- make the error message more informative. the old one was Error ENOENT: New host dael (10.3.64.25) failed to connect: `ssh -F /tmp/cephadm-conf-9tvrgrls -i /tmp/cephadm-identity-sj66ado1 root@10.3.64.25` which was both misleading and had irrelevant information. Now, Error ENOENT: Failed to connect to dael (10.3.64.25). Check that the host is reachable and accepts connections using the cephadm SSH key Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index f8a978947e1b..25134e6161dc 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1465,9 +1465,10 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): """ if not addr and host in self.inventory: addr = self.inventory[host].get('addr', host) - conn, connr = self._get_connection(addr) try: + conn, connr = self._get_connection(addr) + assert image or entity if not image: daemon_type = entity.split('.', 1)[0] # type: ignore @@ -1539,8 +1540,10 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): return out, err, code except execnet.gateway_bootstrap.HostNotFound as e: - raise OrchestratorError('New host %s (%s) failed to connect: `ssh %s`' % ( - host, addr, str(e))) from e + # this is a misleading exception as it seems to be thrown for + # any sort of connection failure, even those having nothing to + # do with "host not found" (e.g., ssh key permission denied). + raise OrchestratorError('Failed to connect to %s (%s). Check that the host is reachable and accepts connections using the cephadm SSH key' % (host, addr)) from e except Exception as ex: self.log.exception(ex) raise