]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: skip virtual cdrom devices in inventory 67624/head
authorUjjawal Anand <ujjawal.anand@ibm.com>
Tue, 3 Mar 2026 05:38:29 +0000 (11:08 +0530)
committerUjjawal Anand <ujjawal.anand@ibm.com>
Wed, 25 Mar 2026 15:49:02 +0000 (21:19 +0530)
-Some hosts expose IPMI/BMC virtual media as /dev/sr0. These
devices are reported as SCSI type 5 (CD/DVD) via sysfs and
appear in inventory/orchestrator output.

-These are not real disks and cannot be used as OSD targets.

-Filter out devices with SCSI type 5 to avoid listing
virtual cdrom devices as valid OSD candidates.

Fixes:https://tracker.ceph.com/issues/75281

Signed-off-by: Ujjawal Anand <ujjawal.anand@ibm.com>
src/ceph-volume/ceph_volume/tests/util/test_disk.py
src/ceph-volume/ceph_volume/util/disk.py

index 68eb944a34c68be24eeed8407b22673f7ebaca9f..bd4b6a2be348f6a1ab17f5b1e6398abe2e972eeb 100644 (file)
@@ -367,6 +367,27 @@ class TestGetDevices(object):
         assert result[lv_path]['human_readable_size'] == '100.00 MB'
 
 
+class TestGetBlockDevsSysfs(object):
+    def test_optical_device_is_skipped(self, fake_filesystem):
+        # sr0 is a CDROM (IPMI/BMC virtual media),not a usable disk.
+        fake_filesystem.create_file('/dev/sr0')
+        fake_filesystem.create_dir('/sys/dev/block')
+        fake_filesystem.create_dir('/sys/block/sr0/holders')
+        fake_filesystem.create_dir('/sys/block/sr0/device')
+        fake_filesystem.create_file('/sys/block/sr0/device/type', contents='5\n')
+
+        assert disk.get_block_devs_sysfs(device='sr0') == []
+
+    def test_regular_device_is_not_skipped(self, fake_filesystem):
+        # normal disk should still be reported.
+        fake_filesystem.create_file('/dev/sda')
+        fake_filesystem.create_dir('/sys/dev/block')
+        fake_filesystem.create_dir('/sys/block/sda/holders')
+
+        result = disk.get_block_devs_sysfs(device='sda')
+        assert result == [['/dev/sda', '/dev/sda', 'disk', '/dev/sda']]
+
+
 class TestSizeCalculations(object):
 
     @pytest.mark.parametrize('aliases', [
index d8871a17437936502ed403aadb5041b6db63c86a..083e2a6007e22880e0785c5e90db2443f38ca892 100644 (file)
@@ -715,6 +715,12 @@ def get_block_devs_sysfs(_sys_block_path: str = '/sys/block', _sys_dev_block_pat
         name = kname = pname = os.path.join("/dev", dev)
         if not os.path.exists(name):
             continue
+        # Exclude any CDROM devices (ex: IPMI devices)
+        # The linux kernel reports these as SCSI device type 5 under /sys/block/<dev>/device/type
+        # and they appear as /dev/sr* (ex: /dev/sr0)
+        # These are not physical disks and are not valid OSD targets, so skip them.
+        if get_file_contents(os.path.join(_sys_block_path, dev, 'device/type'), '').strip() == '5':
+            continue
         type_: str = 'disk'
         holders: List[str] = os.listdir(os.path.join(_sys_block_path, dev, 'holders'))
         if holder_inner_loop():