]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: skip virtual cdrom devices in inventory 68108/head
authorUjjawal Anand <ujjawal.anand@ibm.com>
Tue, 3 Mar 2026 05:38:29 +0000 (11:08 +0530)
committerGuillaume Abrioux <gabrioux@ibm.com>
Mon, 30 Mar 2026 13:56:47 +0000 (13:56 +0000)
-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>
(cherry picked from commit 3706288bc050bb20d64fc9ac6a643aaf84ca041d)

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

index 6abe8571b4e86cddfdd14397689bde5b91ee4124..05bbb4575464cac0bd4b796b85a36bbc028c6b3c 100644 (file)
@@ -345,6 +345,27 @@ class TestGetDevices(object):
         assert result[sda_path]['actuators'] == fake_actuator_nb
 
 
+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 31b35bb566df2c18225717614e686275e927d0b1..f4f25b9f8b50c885820b9898f03f7ac45b6cdb5b 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():