From: Sebastian Wagner Date: Fri, 20 Mar 2020 14:13:26 +0000 (+0100) Subject: mgr/cephadm: in-memory set of offline hosts X-Git-Tag: v15.2.2~76^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f6e6aae49eb7e2adaeabe9abcf7639455ff5a14f;p=ceph.git mgr/cephadm: in-memory set of offline hosts Fixes: https://tracker.ceph.com/issues/43839 Signed-off-by: Sebastian Wagner (cherry picked from commit 05cf5796f36bc2d826a29aff4a124124df87cbc6) --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 5d3e4c03cdec..d78986a27a90 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -707,6 +707,9 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): if h not in self.inventory: self.cache.rm_host(h) + # in-memory only. + self.offline_hosts: Set[str] = set() + def shutdown(self): self.log.debug('shutdown') self._worker_pool.close() @@ -1306,6 +1309,11 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): conn.exit() self._cons = {} + def offline_hosts_remove(self, host): + if host in self.offline_hosts: + self.offline_hosts.remove(host) + + @staticmethod def can_run(): if remoto is not None: @@ -1532,6 +1540,8 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): if not addr and host in self.inventory: addr = self.inventory[host].get('addr', host) + self.offline_hosts_remove(host) + try: try: conn, connr = self._get_connection(addr) @@ -1616,6 +1626,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): # 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) 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' \ @@ -1654,6 +1665,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): self.inventory[spec.hostname] = spec.to_json() self._save_inventory() self.cache.prime_empty_host(spec.hostname) + self.offline_hosts_remove(spec.hostname) self.event.set() # refresh stray health check self.log.info('Added host %s' % spec.hostname) return "Added host '{}'".format(spec.hostname) @@ -1700,7 +1712,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): hostname, addr=info.get('addr', hostname), labels=info.get('labels', []), - status=info.get('status', ''), + status='Offline' if hostname in self.offline_hosts else info.get('status', ''), )) return r