From 23a0eaa8afbb17cc18070ef01f7351bd4ae1a378 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Wed, 11 Sep 2024 15:37:59 +0000 Subject: [PATCH] ceph-volume: add call to `ceph-bluestore-tool zap-device` BlueStore now writes its metadata at multiple offset on devices [1]. It means `ceph-volume lvm zap` doesn't remove BlueStore signature altogether. This can confuse ceph-volume when redeploying an OSD on a previously zapped device because there is still old BlueStore metadata on it. ceph-volume should call `ceph-bluestore-tool zap-device` [2] in addition to the existing calls when wiping a device. [1] https://github.com/ceph/ceph/pull/55374 [2] https://github.com/ceph/ceph/pull/59632 Fixes: https://tracker.ceph.com/issues/68035 Signed-off-by: Guillaume Abrioux (cherry picked from commit dcf743928e301c3724a2b7c4d13c0be8ea0714d7) --- .../ceph_volume/devices/lvm/zap.py | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/ceph-volume/ceph_volume/devices/lvm/zap.py b/src/ceph-volume/ceph_volume/devices/lvm/zap.py index f512a3bde1d7c..c1bef82c10975 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/zap.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/zap.py @@ -16,6 +16,31 @@ logger = logging.getLogger(__name__) mlogger = terminal.MultiLogger(__name__) +def zap_device(path: str) -> None: + """Remove any existing filesystem signatures. + + Args: + path (str): The path to the device to zap. + """ + zap_bluestore(path) + wipefs(path) + zap_data(path) + +def zap_bluestore(path: str) -> None: + """Remove all BlueStore signature on a device. + + Args: + path (str): The path to the device to remove BlueStore signatures from. + """ + terminal.info(f'Removing all BlueStore signature on {path} if any...') + process.run([ + 'ceph-bluestore-tool', + 'zap-device', + '--dev', + path, + '--yes-i-really-really-mean-it' + ]) + def wipefs(path): """ Removes the filesystem from an lv or partition. @@ -170,8 +195,7 @@ class Zap(object): device.vg_name}) self.unmount_lv(lv) - wipefs(device.path) - zap_data(device.path) + zap_device(device.path) if self.args.destroy: lvs = api.get_lvs(filters={'vg_name': device.vg_name}) @@ -217,8 +241,7 @@ class Zap(object): mlogger.info("Unmounting %s", device.path) system.unmount(device.path) - wipefs(device.path) - zap_data(device.path) + zap_device(device.path) if self.args.destroy: mlogger.info("Destroying partition since --destroy was used: %s" % device.path) @@ -263,8 +286,7 @@ class Zap(object): for part_name in device.sys_api.get('partitions', {}).keys(): self.zap_partition(Device('/dev/%s' % part_name)) - wipefs(device.path) - zap_data(device.path) + zap_device(device.path) @decorators.needs_root def zap(self, devices=None): -- 2.39.5