From: Ujjawal Anand Date: Tue, 3 Mar 2026 05:38:29 +0000 (+0530) Subject: ceph-volume: skip virtual cdrom devices in inventory X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3706288bc050bb20d64fc9ac6a643aaf84ca041d;p=ceph.git ceph-volume: skip virtual cdrom devices in inventory -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 --- diff --git a/src/ceph-volume/ceph_volume/tests/util/test_disk.py b/src/ceph-volume/ceph_volume/tests/util/test_disk.py index 68eb944a34c6..bd4b6a2be348 100644 --- a/src/ceph-volume/ceph_volume/tests/util/test_disk.py +++ b/src/ceph-volume/ceph_volume/tests/util/test_disk.py @@ -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', [ diff --git a/src/ceph-volume/ceph_volume/util/disk.py b/src/ceph-volume/ceph_volume/util/disk.py index d8871a174379..083e2a6007e2 100644 --- a/src/ceph-volume/ceph_volume/util/disk.py +++ b/src/ceph-volume/ceph_volume/util/disk.py @@ -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//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():