]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: filter RBD devices from the device inventory
authorMichael Fritch <mfritch@suse.com>
Tue, 18 Jan 2022 22:15:45 +0000 (15:15 -0700)
committerGuillaume Abrioux <gabrioux@redhat.com>
Tue, 2 Aug 2022 09:18:24 +0000 (11:18 +0200)
Avoid running `blkid` or deploying OSDs on RBD devices by ensuring they
do not appear in the `ceph-volume inventory`

Fixes: https://tracker.ceph.com/issues/53846
Signed-off-by: Michael Fritch <mfritch@suse.com>
(cherry picked from commit 47325ec3ec5ce1d53c5eae2952f631e95b7135fe)

src/ceph-volume/ceph_volume/tests/util/test_disk.py
src/ceph-volume/ceph_volume/util/disk.py

index 65fd994a795aa80a59032a18c705b0ac80e39cb0..217bb81fad06df97843e1a890917dcd3eb62003e 100644 (file)
@@ -331,6 +331,15 @@ class TestGetDevices(object):
         result = disk.get_devices(_sys_block_path=block_path)
         assert result[sda_path]['rotational'] == '1'
 
+    def test_is_ceph_rbd(self, tmpfile, tmpdir, patched_get_block_devs_lsblk):
+        rbd_path = '/dev/rbd0'
+        patched_get_block_devs_lsblk.return_value = [[rbd_path, rbd_path, 'disk']]
+        block_path = self.setup_path(tmpdir)
+        block_rbd_path = os.path.join(block_path, 'rbd0')
+        os.makedirs(block_rbd_path)
+        result = disk.get_devices(_sys_block_path=block_path)
+        assert rbd_path not in result
+
 
 class TestSizeCalculations(object):
 
index 00e9f2a44f9832d57d3106415ef9cc0a2b668bd4..37b52ee04828dbd6eae9b47882a0af2f504c56d5 100644 (file)
@@ -373,6 +373,13 @@ def is_partition(dev):
     return False
 
 
+def is_ceph_rbd(dev):
+    """
+    Boolean to determine if a given device is a ceph RBD device, like /dev/rbd0
+    """
+    return dev.startswith(('/dev/rbd'))
+
+
 class BaseFloatUnit(float):
     """
     Base class to support float representations of size values. Suffix is
@@ -840,6 +847,10 @@ def get_devices(_sys_block_path='/sys/block', device=''):
         sysdir = os.path.join(_sys_block_path, devname)
         metadata = {}
 
+        # If the device is ceph rbd it gets excluded
+        if is_ceph_rbd(diskname):
+            continue
+
         # If the mapper device is a logical volume it gets excluded
         if is_mapper_device(diskname):
             if lvm.get_device_lvs(diskname):