From 29bff27ccfcbaac1b008b03354736c35b629e81a Mon Sep 17 00:00:00 2001 From: Adam King Date: Fri, 21 Oct 2022 14:41:03 -0400 Subject: [PATCH] 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 --- src/pybind/mgr/cephadm/module.py | 4 ++++ src/pybind/mgr/cephadm/tests/test_ssh.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 1a523ed9f981d..a8e17b1dfbb87 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1098,6 +1098,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 3282295e5ca93..4197d8d7ef0ed 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() -- 2.39.5