]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: add call to `ceph-bluestore-tool zap-device` 59968/head
authorGuillaume Abrioux <gabrioux@ibm.com>
Wed, 11 Sep 2024 15:37:59 +0000 (15:37 +0000)
committerGuillaume Abrioux <gabrioux@ibm.com>
Wed, 25 Sep 2024 07:01:05 +0000 (07:01 +0000)
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 <gabrioux@ibm.com>
(cherry picked from commit dcf743928e301c3724a2b7c4d13c0be8ea0714d7)

src/ceph-volume/ceph_volume/devices/lvm/zap.py

index f512a3bde1d7cef96e9a840e1f020eb2df946410..c1bef82c109750082b5af43ed0b5cf2607996aab 100644 (file)
@@ -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):