From a88e30deda19b9f1544c1ca1f731f0fa647991c0 Mon Sep 17 00:00:00 2001 From: Adam King Date: Mon, 16 Oct 2023 15:15:54 -0400 Subject: [PATCH] mgr/cephadm: warn when draining host explicitly listed in placement In the case you apply a spec like ``` service_type: node-exporter placement: hosts: - host3 ``` and then you run `ceph orch host drain host3`, cephadm will remove the daemon from that host and the placement would now match nothing. This is definitely an issue that should be able to be bypassed as it generally isn't serious, but it would be good to let users know they have the host listed explicitly in placements like this when they want to drain it. Fixes: https://tracker.ceph.com/issues/63220 Signed-off-by: Adam King (cherry picked from commit 434e5fe6aa69cad11454d437002015cff55b727a) --- src/pybind/mgr/cephadm/module.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index ae97f5b631fcf..bb23564d95fa9 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -3516,6 +3516,18 @@ Then run the following: 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.") + # if the user has specified the host we are going to drain + # explicitly in any service spec, warn the user. Having a + # drained host listed in a placement provides no value, so + # they may want to fix it. + services_matching_drain_host: List[str] = [] + for sname, sspec in self.spec_store.all_specs.items(): + if sspec.placement.hosts and hostname in [h.hostname for h in sspec.placement.hosts]: + services_matching_drain_host.append(sname) + if services_matching_drain_host: + raise OrchestratorValidationError(f'Host {hostname} was found explicitly listed in the placements ' + f'of services:\n {services_matching_drain_host}.\nPlease update those ' + 'specs to not list this host.\nThis warning can be bypassed with --force') self.add_host_label(hostname, '_no_schedule') if not keep_conf_keyring: -- 2.39.5