]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Merge pull request #35576 from sebastian-philipp/cephadm-etc-ceph-ceph-conf
authorSebastian Wagner <sebastian.wagner@suse.com>
Tue, 30 Jun 2020 08:50:21 +0000 (10:50 +0200)
committerGitHub <noreply@github.com>
Tue, 30 Jun 2020 08:50:21 +0000 (10:50 +0200)
mgr/cephadm: Manage /etc/ceph/ceph.conf

Reviewed-by: Joshua Schmid <jschmid@suse.de>
Reviewed-by: Michael Fritch <mfritch@suse.com>
1  2 
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/tests/test_cephadm.py

index 6ecb117be57fdc0eb857c0f17834c032ad7f3e49,fe58d866d2a5a5c9a98f5b5f4ad86d43a2cd3716..793b8355d23d65fcd66bf1af0ecc07f02ef464ec
@@@ -869,17 -914,57 +892,57 @@@ class CephadmOrchestrator(orchestrator.
              executable_path))
          return executable_path
  
+     @contextmanager
+     def _remote_connection(self,
+                            host: str,
+                            addr: Optional[str]=None,
+                            ) -> Iterator[Tuple["BaseConnection", Any]]:
+         if not addr and host in self.inventory:
+             addr = self.inventory.get_addr(host)
+         self.offline_hosts_remove(host)
+         try:
+             try:
+                 conn, connr = self._get_connection(addr)
+             except OSError as e:
+                 self._reset_con(host)
+                 msg = f"Can't communicate with remote host `{addr}`, possibly because python3 is not installed there: {str(e)}"
+                 raise execnet.gateway_bootstrap.HostNotFound(msg)
+             yield (conn, connr)
+         except execnet.gateway_bootstrap.HostNotFound as 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).
+             self.offline_hosts.add(host)
+             self._reset_con(host)
+             user = 'root' if self.mode == 'root' else 'cephadm'
+             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)
+             raise
      def _run_cephadm(self,
                       host: str,
 -                     entity: Optional[str],
 +                     entity: str,
                       command: str,
                       args: List[str],
 -                     addr: Optional[str] = None,
 -                     stdin: Optional[str] = None,
 -                     no_fsid=False,
 -                     error_ok=False,
 -                     image: Optional[str] = None,
 -                     env_vars: Optional[List[str]] = None,
 +                     addr: Optional[str] = "",
 +                     stdin: Optional[str] = "",
 +                     no_fsid: Optional[bool] = False,
 +                     error_ok: Optional[bool] = False,
 +                     image: Optional[str] = "",
 +                     env_vars: Optional[List[str]]= None,
                       ) -> Tuple[List[str], List[str], int]:
          """
          Run cephadm on the remote host with the given command + args