]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: osd replacement improvement 51213/head
authorGuillaume Abrioux <gabrioux@ibm.com>
Fri, 31 Mar 2023 09:27:13 +0000 (11:27 +0200)
committerAdam King <adking@redhat.com>
Tue, 25 Apr 2023 17:00:46 +0000 (13:00 -0400)
This adds a new parameter `--no-destroy` to the command
`ceph orch osd rm`.

By default, it removes any VGs/LVs related to the osd being removed.
For specific workflows, this can be useful to preserve them.

Fixes: https://tracker.ceph.com/issues/59289
Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
(cherry picked from commit ef810a4ebf91b538f778da4ca3ea0fdc2968e2fe)

src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/services/osd.py
src/pybind/mgr/orchestrator/_interface.py
src/pybind/mgr/orchestrator/module.py

index 9134ce2bdc0827398c27c702e2206dcb2c19c653..66e55a53d2015bb9e07bf4c6ba0a819495152a45 100644 (file)
@@ -2879,7 +2879,8 @@ Then run the following:
     def remove_osds(self, osd_ids: List[str],
                     replace: bool = False,
                     force: bool = False,
-                    zap: bool = False) -> str:
+                    zap: bool = False,
+                    no_destroy: bool = False) -> str:
         """
         Takes a list of OSDs and schedules them for removal.
         The function that takes care of the actual removal is
@@ -2901,6 +2902,7 @@ Then run the following:
                                                 replace=replace,
                                                 force=force,
                                                 zap=zap,
+                                                no_destroy=no_destroy,
                                                 hostname=daemon.hostname,
                                                 process_started_at=datetime_now(),
                                                 remove_util=self.to_remove_osds.rm_util))
index 5899ba49a98e2b7a9182ba26312b2bd3135eb9e8..93ebb7c7667f7ec555d4600ed88613af01ca751a 100644 (file)
@@ -537,9 +537,12 @@ class RemoveUtil(object):
     def zap_osd(self, osd: "OSD") -> str:
         "Zaps all devices that are associated with an OSD"
         if osd.hostname is not None:
+            cmd = ['--', 'lvm', 'zap', '--osd-id', str(osd.osd_id)]
+            if not osd.no_destroy:
+                cmd.append('--destroy')
             out, err, code = CephadmServe(self.mgr)._run_cephadm(
                 osd.hostname, 'osd', 'ceph-volume',
-                ['--', 'lvm', 'zap', '--destroy', '--osd-id', str(osd.osd_id)],
+                cmd,
                 error_ok=True)
             self.mgr.cache.invalidate_host_devices(osd.hostname)
             if code:
@@ -602,7 +605,8 @@ class OSD:
                  replace: bool = False,
                  force: bool = False,
                  hostname: Optional[str] = None,
-                 zap: bool = False):
+                 zap: bool = False,
+                 no_destroy: bool = False):
         # the ID of the OSD
         self.osd_id = osd_id
 
@@ -641,6 +645,8 @@ class OSD:
 
         # Whether devices associated with the OSD should be zapped (DATA ERASED)
         self.zap = zap
+        # Whether all associated LV devices should be destroyed.
+        self.no_destroy = no_destroy
 
     def start(self) -> None:
         if self.started:
index 148b8990968f40e92d8094b7cec5316de200abb4..db69459076820e5bd99c6cf32c721c6cd77bd2b4 100644 (file)
@@ -571,12 +571,14 @@ class Orchestrator(object):
     def remove_osds(self, osd_ids: List[str],
                     replace: bool = False,
                     force: bool = False,
-                    zap: bool = False) -> OrchResult[str]:
+                    zap: bool = False,
+                    no_destroy: bool = False) -> OrchResult[str]:
         """
         :param osd_ids: list of OSD IDs
         :param replace: marks the OSD as being destroyed. See :ref:`orchestrator-osd-replace`
         :param force: Forces the OSD removal process without waiting for the data to be drained first.
         :param zap: Zap/Erase all devices associated with the OSDs (DESTROYS DATA)
+        :param no_destroy: Do not destroy associated VGs/LVs with the OSD.
 
         .. note:: this can only remove OSDs that were successfully
             created (i.e. got an OSD ID).
index eff48e8ca7a065c0fd1438a6b1fdeb331079422d..ff360bb0503e8c235ca458acdf3dcc3f451f9093 100644 (file)
@@ -846,9 +846,11 @@ Usage:
                       osd_id: List[str],
                       replace: bool = False,
                       force: bool = False,
-                      zap: bool = False) -> HandleCommandResult:
+                      zap: bool = False,
+                      no_destroy: bool = False) -> HandleCommandResult:
         """Remove OSD daemons"""
-        completion = self.remove_osds(osd_id, replace=replace, force=force, zap=zap)
+        completion = self.remove_osds(osd_id, replace=replace, force=force,
+                                      zap=zap, no_destroy=no_destroy)
         raise_if_exception(completion)
         return HandleCommandResult(stdout=completion.result_str())