From: Adam King Date: Fri, 21 Oct 2022 18:41:03 +0000 (-0400) Subject: mgr/cephadm: update check-host to handle new HostConnectionError exception X-Git-Tag: v17.2.6~71^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=164ac00b00d5423afafa8612c4e6e3c73f96408c;p=ceph.git mgr/cephadm: update check-host to handle new HostConnectionError exception Otherwise we'll return a message about the host not being found and to check 'ceph orch host ls' when the actual problem is the host being offline Signed-off-by: Adam King (cherry picked from commit 29bff27ccfcbaac1b008b03354736c35b629e81a) --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 0d5e6edc91a1..bd02b3527ae0 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1060,6 +1060,10 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule, error_ok=True, no_fsid=True)) if code: return 1, '', ('check-host failed:\n' + '\n'.join(err)) + except ssh.HostConnectionError as e: + self.log.exception(f"check-host failed for '{host}' at addr ({e.addr}) due to connection failure: {str(e)}") + return 1, '', ('check-host failed:\n' + + f"Failed to connect to {host} at address ({e.addr}): {str(e)}") except OrchestratorError: self.log.exception(f"check-host failed for '{host}'") return 1, '', ('check-host failed:\n' diff --git a/src/pybind/mgr/cephadm/tests/test_ssh.py b/src/pybind/mgr/cephadm/tests/test_ssh.py index 3282295e5ca9..4197d8d7ef0e 100644 --- a/src/pybind/mgr/cephadm/tests/test_ssh.py +++ b/src/pybind/mgr/cephadm/tests/test_ssh.py @@ -38,7 +38,7 @@ class TestWithSSH: asyncssh_connect.side_effect = ConnectionLost('reason') code, out, err = cephadm_module.check_host('test') assert out == '' - assert "Host 'test' not found" in err + assert "Failed to connect to test at address (1::4)" in err out = wait(cephadm_module, cephadm_module.get_hosts())[0].to_json() assert out == HostSpec('test', '1::4', status='Offline').to_json()