]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: validate host label before removing 53112/head
authorRedouane Kachach <rkachach@redhat.com>
Mon, 29 May 2023 16:10:15 +0000 (18:10 +0200)
committerAdam King <adking@redhat.com>
Wed, 23 Aug 2023 20:06:08 +0000 (16:06 -0400)
Fixes: https://tracker.ceph.com/issues/61494
Signed-off-by: Redouane Kachach <rkachach@redhat.com>
(cherry picked from commit 9eaafb90311053c4241b471092108cbaf3352c23)

src/pybind/mgr/cephadm/module.py

index 37fe3b4ac58f0756c1f192799ce3a7ff66e30ee5..66418d6c7837bbf4a42fb792b8a07ed254804b7e 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")