]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: validate host label before removing 51817/head
authorRedouane Kachach <rkachach@redhat.com>
Mon, 29 May 2023 16:10:15 +0000 (18:10 +0200)
committerRedouane Kachach <rkachach@redhat.com>
Tue, 30 May 2023 09:21:29 +0000 (11:21 +0200)
Fixes: https://tracker.ceph.com/issues/61494
Signed-off-by: Redouane Kachach <rkachach@redhat.com>
src/pybind/mgr/cephadm/module.py

index 272c83261b0fdd88c7e49034e52afc2dc99380d3..a17e22a23701c4f880d236ae8cce271f0c46ada0 100644 (file)
@@ -1739,10 +1739,14 @@ Then run the following:
                                                   "It is recommended to add the _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")