From 23514a5529f4e7aca8f51c55c7895b76fca87551 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 14 Mar 2020 10:07:34 -0500 Subject: [PATCH] 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 --- src/pybind/mgr/cephadm/module.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index f8a978947e1..25134e6161d 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 -- 2.39.5