]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: warn when draining host explicitly listed in placement
authorAdam King <adking@redhat.com>
Mon, 16 Oct 2023 19:15:54 +0000 (15:15 -0400)
committerAdam King <adking@redhat.com>
Wed, 13 Mar 2024 02:42:25 +0000 (22:42 -0400)
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 <adking@redhat.com>
(cherry picked from commit 434e5fe6aa69cad11454d437002015cff55b727a)

src/pybind/mgr/cephadm/module.py

index ae97f5b631fcfef42ee5a4166d413f8e9d7efdda..bb23564d95fa9b62aa03f78f835d21aeaafb0e4a 100644 (file)
@@ -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: