From: Sebastian Wagner Date: Tue, 30 Jun 2020 08:50:21 +0000 (+0200) Subject: Merge pull request #35576 from sebastian-philipp/cephadm-etc-ceph-ceph-conf X-Git-Tag: v16.1.0~1885 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e5d8df1a7af851b523ce68fd09b2e84d234ad5b8;p=ceph.git Merge pull request #35576 from sebastian-philipp/cephadm-etc-ceph-ceph-conf mgr/cephadm: Manage /etc/ceph/ceph.conf Reviewed-by: Joshua Schmid Reviewed-by: Michael Fritch --- e5d8df1a7af851b523ce68fd09b2e84d234ad5b8 diff --cc src/pybind/mgr/cephadm/module.py index 6ecb117be57,fe58d866d2a..793b8355d23 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@@ -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