]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: Proper error for OSErrors
authorSebastian Wagner <sebastian.wagner@suse.com>
Tue, 12 May 2020 13:20:57 +0000 (15:20 +0200)
committerSebastian Wagner <sebastian.wagner@suse.com>
Tue, 12 May 2020 13:20:57 +0000 (15:20 +0200)
Previsously, an OSError resulted in

    OSError: cannot send (already closed?)

which is not helpful.

Fixes: https://tracker.ceph.com/issues/45032
Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
src/pybind/mgr/cephadm/module.py

index 3e3c8d1a0b22ccc751c8622e477520525de335e6..f02f094ac00021570ab7e8ec61ed4c0cd7422c22 100644 (file)
@@ -924,11 +924,11 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
         try:
             try:
                 conn, connr = self._get_connection(addr)
-            except IOError as e:
+            except OSError as e:
                 if error_ok:
                     self.log.exception('failed to establish ssh connection')
                     return [], [str("Can't communicate with remote host, possibly because python3 is not installed there")], 1
-                raise
+                raise execnet.gateway_bootstrap.HostNotFound(str(e)) from e
 
             assert image or entity
             if not image:
@@ -1008,10 +1008,13 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
             # do with "host not found" (e.g., ssh key permission denied).
             self.offline_hosts.add(host)
             user = 'root' if self.mode == 'root' else 'cephadm'
-            msg = f'Failed to connect to {host} ({addr}).  ' \
-                  f'Check that the host is reachable and accepts connections using the cephadm SSH key\n' \
-                  f'you may want to run: \n' \
-                  f'> ssh -F =(ceph cephadm get-ssh-config) -i =(ceph config-key get mgr/cephadm/ssh_identity_key) {user}@{host}'
+            msg = f'''Failed to connect to {host} ({addr}).
+Check that the host is reachable and accepts connections using the cephadm SSH key
+
+you may want to run:
+> ceph cephadm get-ssh-config > ssh_config
+> ceph config-key get mgr/cephadm/ssh_identity_key > key
+> ssh -F ssh_config -i key {user}@{host}'''
             raise OrchestratorError(msg) from e
         except Exception as ex:
             self.log.exception(ex)