Skip to content

Commit 300e3ee

Browse files
authored
Merge pull request ceph#50838 from guits/osd-replacement-improvements
orchestrator: add `--no-destroy` arg to `ceph orch osd rm`
2 parents bfa8bd1 + ef810a4 commit 300e3ee

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

src/pybind/mgr/cephadm/module.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3172,7 +3172,8 @@ def upgrade_stop(self) -> str:
31723172
def remove_osds(self, osd_ids: List[str],
31733173
replace: bool = False,
31743174
force: bool = False,
3175-
zap: bool = False) -> str:
3175+
zap: bool = False,
3176+
no_destroy: bool = False) -> str:
31763177
"""
31773178
Takes a list of OSDs and schedules them for removal.
31783179
The function that takes care of the actual removal is
@@ -3194,6 +3195,7 @@ def remove_osds(self, osd_ids: List[str],
31943195
replace=replace,
31953196
force=force,
31963197
zap=zap,
3198+
no_destroy=no_destroy,
31973199
hostname=daemon.hostname,
31983200
process_started_at=datetime_now(),
31993201
remove_util=self.to_remove_osds.rm_util))

src/pybind/mgr/cephadm/services/osd.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,12 @@ def reweight_osd(self, osd: "OSD", weight: float) -> bool:
542542
def zap_osd(self, osd: "OSD") -> str:
543543
"Zaps all devices that are associated with an OSD"
544544
if osd.hostname is not None:
545+
cmd = ['--', 'lvm', 'zap', '--osd-id', str(osd.osd_id)]
546+
if not osd.no_destroy:
547+
cmd.append('--destroy')
545548
out, err, code = self.mgr.wait_async(CephadmServe(self.mgr)._run_cephadm(
546549
osd.hostname, 'osd', 'ceph-volume',
547-
['--', 'lvm', 'zap', '--destroy', '--osd-id', str(osd.osd_id)],
550+
cmd,
548551
error_ok=True))
549552
self.mgr.cache.invalidate_host_devices(osd.hostname)
550553
if code:
@@ -608,7 +611,8 @@ def __init__(self,
608611
replace: bool = False,
609612
force: bool = False,
610613
hostname: Optional[str] = None,
611-
zap: bool = False):
614+
zap: bool = False,
615+
no_destroy: bool = False):
612616
# the ID of the OSD
613617
self.osd_id = osd_id
614618

@@ -647,6 +651,8 @@ def __init__(self,
647651

648652
# Whether devices associated with the OSD should be zapped (DATA ERASED)
649653
self.zap = zap
654+
# Whether all associated LV devices should be destroyed.
655+
self.no_destroy = no_destroy
650656

651657
def start(self) -> None:
652658
if self.started:

src/pybind/mgr/orchestrator/_interface.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,12 +589,14 @@ def preview_osdspecs(self,
589589
def remove_osds(self, osd_ids: List[str],
590590
replace: bool = False,
591591
force: bool = False,
592-
zap: bool = False) -> OrchResult[str]:
592+
zap: bool = False,
593+
no_destroy: bool = False) -> OrchResult[str]:
593594
"""
594595
:param osd_ids: list of OSD IDs
595596
:param replace: marks the OSD as being destroyed. See :ref:`orchestrator-osd-replace`
596597
:param force: Forces the OSD removal process without waiting for the data to be drained first.
597598
:param zap: Zap/Erase all devices associated with the OSDs (DESTROYS DATA)
599+
:param no_destroy: Do not destroy associated VGs/LVs with the OSD.
598600
599601
600602
.. note:: this can only remove OSDs that were successfully

src/pybind/mgr/orchestrator/module.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,9 +1000,11 @@ def _osd_rm_start(self,
10001000
osd_id: List[str],
10011001
replace: bool = False,
10021002
force: bool = False,
1003-
zap: bool = False) -> HandleCommandResult:
1003+
zap: bool = False,
1004+
no_destroy: bool = False) -> HandleCommandResult:
10041005
"""Remove OSD daemons"""
1005-
completion = self.remove_osds(osd_id, replace=replace, force=force, zap=zap)
1006+
completion = self.remove_osds(osd_id, replace=replace, force=force,
1007+
zap=zap, no_destroy=no_destroy)
10061008
raise_if_exception(completion)
10071009
return HandleCommandResult(stdout=completion.result_str())
10081010

src/pybind/mgr/rook/module.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,12 @@ def _save_drive_groups(self) -> None:
625625
}
626626
self.set_store("drive_group_map", json.dumps(json_drive_group_map))
627627

628-
def remove_osds(self, osd_ids: List[str], replace: bool = False, force: bool = False, zap: bool = False) -> OrchResult[str]:
628+
def remove_osds(self,
629+
osd_ids: List[str],
630+
replace: bool = False,
631+
force: bool = False,
632+
zap: bool = False,
633+
no_destroy: bool = False) -> OrchResult[str]:
629634
assert self._rook_cluster is not None
630635
if zap:
631636
raise RuntimeError("Rook does not support zapping devices during OSD removal.")

0 commit comments

Comments
 (0)