From: Adam King <47704447+adk3798@users.noreply.github.com> Date: Thu, 31 Aug 2023 17:33:45 +0000 (-0400) Subject: Merge pull request #53123 from adk3798/wip-62530-reef X-Git-Tag: v18.2.1~327 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4697f18cbc5d14433a0d215f9965dbd92e27b050;p=ceph.git Merge pull request #53123 from adk3798/wip-62530-reef reef: mgr/cephadm: allow draining host without removing conf/keyring files Reviewed-by: John Mulligan --- 4697f18cbc5d14433a0d215f9965dbd92e27b050 diff --cc src/pybind/mgr/cephadm/module.py index 227017b61a87,3fa6b4d8bd3e..2e58d80354e1 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@@ -1724,24 -1729,20 +1724,24 @@@ Then run the following def remove_host_label(self, host: str, label: str, force: bool = False) -> str: # if we remove the _admin label from the only host that has it we could end up # removing the only instance of the config and keyring and cause issues - if not force and label == '_admin': - p = PlacementSpec(label='_admin') + if not force and label == SpecialHostLabels.ADMIN: + p = PlacementSpec(label=SpecialHostLabels.ADMIN) admin_hosts = p.filter_matching_hostspecs(self.inventory.all_specs()) if len(admin_hosts) == 1 and admin_hosts[0] == host: - raise OrchestratorValidationError(f"Host {host} is the last host with the '_admin'" - " label.\nRemoving the _admin label from this host could cause the removal" + raise OrchestratorValidationError(f"Host {host} is the last host with the '{SpecialHostLabels.ADMIN}'" + f" label.\nRemoving the {SpecialHostLabels.ADMIN} label from this host could cause the removal" " of the last cluster config/keyring managed by cephadm.\n" - "It is recommended to add the _admin label to another host" + f"It is recommended to add the {SpecialHostLabels.ADMIN} label to another host" " before completing this operation.\nIf you're certain this is" " what you want rerun this command with --force.") - self.inventory.rm_label(host, label) - self.log.info('Removed label %s to host %s' % (label, host)) + if self.inventory.has_label(host, label): + self.inventory.rm_label(host, label) + msg = f'Removed label {label} from host {host}' + else: + msg = f"Host {host} does not have label '{label}'. Please use 'ceph orch host ls' to list all the labels." + self.log.info(msg) self._kick_serve_loop() - return 'Removed label %s from host %s' % (label, host) + return msg def _host_ok_to_stop(self, hostname: str, force: bool = False) -> Tuple[int, str]: self.log.debug("running host-ok-to-stop checks")