diff options
author | Guillaume Abrioux <gabrioux@ibm.com> | 2023-08-10 10:01:12 +0200 |
---|---|---|
committer | Guillaume Abrioux <gabrioux@ibm.com> | 2023-08-10 11:08:52 +0200 |
commit | 2422ad867dff9d526d7e8be543178c897991097f (patch) | |
tree | 0f82294f9be7fa1322b893b624605cf626e5d506 /src/ceph-volume/ceph_volume/tests/util | |
parent | ceph-volume: add two unit tests (diff) | |
download | ceph-2422ad867dff9d526d7e8be543178c897991097f.tar.xz ceph-2422ad867dff9d526d7e8be543178c897991097f.zip |
ceph-volume: drop is_locked_raw_device()
This functions works for what it is supposed to do:
check if a device is busy.
That being said, this induces a race condition in `get_devices()`
Indeed, it does:
1/ `os.open()` with `(os.O_RDWR | os.O_EXCL)`
2/ `os.close()`
The second call has an effect: it triggers a udev event which causes
systemd-udevd to re-process the device. This seems to be a question of
millisecond but because of this, /sys (sysfs) isn't fully populated as
expected. Given that get_devices() collects a lot of details from sysfs
in a loop, some of these details can be missed.
ceph-volume overall doesn't make decisions based on `is_locked_raw_device()`
This detail is used only for reporting (inventory).
For this reason, dropping this function seems reasonnable.
As a compromise, we can check if the device has partitions and/or a FileSystem
on it.
Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
Diffstat (limited to 'src/ceph-volume/ceph_volume/tests/util')
-rw-r--r-- | src/ceph-volume/ceph_volume/tests/util/test_disk.py | 8 |
1 files changed, 0 insertions, 8 deletions
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 f9e2b76b27d..f71aeb21a23 100644 --- a/src/ceph-volume/ceph_volume/tests/util/test_disk.py +++ b/src/ceph-volume/ceph_volume/tests/util/test_disk.py @@ -225,7 +225,6 @@ class TestGetDevices(object): result = disk.get_devices(_sys_block_path=str(tmpdir)) assert result == {} - @patch('ceph_volume.util.disk.is_locked_raw_device', lambda x: False) def test_sda_block_is_found(self, patched_get_block_devs_sysfs, fake_filesystem): sda_path = '/dev/sda' patched_get_block_devs_sysfs.return_value = [[sda_path, sda_path, 'disk']] @@ -235,7 +234,6 @@ class TestGetDevices(object): assert result[sda_path]['model'] == '' assert result[sda_path]['partitions'] == {} - @patch('ceph_volume.util.disk.is_locked_raw_device', lambda x: False) def test_sda_size(self, patched_get_block_devs_sysfs, fake_filesystem): sda_path = '/dev/sda' patched_get_block_devs_sysfs.return_value = [[sda_path, sda_path, 'disk']] @@ -244,7 +242,6 @@ class TestGetDevices(object): assert list(result.keys()) == [sda_path] assert result[sda_path]['human_readable_size'] == '512.00 KB' - @patch('ceph_volume.util.disk.is_locked_raw_device', lambda x: False) def test_sda_sectorsize_fallsback(self, patched_get_block_devs_sysfs, fake_filesystem): # if no sectorsize, it will use queue/hw_sector_size sda_path = '/dev/sda' @@ -254,7 +251,6 @@ class TestGetDevices(object): assert list(result.keys()) == [sda_path] assert result[sda_path]['sectorsize'] == '1024' - @patch('ceph_volume.util.disk.is_locked_raw_device', lambda x: False) def test_sda_sectorsize_from_logical_block(self, patched_get_block_devs_sysfs, fake_filesystem): sda_path = '/dev/sda' patched_get_block_devs_sysfs.return_value = [[sda_path, sda_path, 'disk']] @@ -262,7 +258,6 @@ class TestGetDevices(object): result = disk.get_devices() assert result[sda_path]['sectorsize'] == '99' - @patch('ceph_volume.util.disk.is_locked_raw_device', lambda x: False) def test_sda_sectorsize_does_not_fallback(self, patched_get_block_devs_sysfs, fake_filesystem): sda_path = '/dev/sda' patched_get_block_devs_sysfs.return_value = [[sda_path, sda_path, 'disk']] @@ -271,7 +266,6 @@ class TestGetDevices(object): result = disk.get_devices() assert result[sda_path]['sectorsize'] == '99' - @patch('ceph_volume.util.disk.is_locked_raw_device', lambda x: False) def test_is_rotational(self, patched_get_block_devs_sysfs, fake_filesystem): sda_path = '/dev/sda' patched_get_block_devs_sysfs.return_value = [[sda_path, sda_path, 'disk']] @@ -279,14 +273,12 @@ class TestGetDevices(object): result = disk.get_devices() assert result[sda_path]['rotational'] == '1' - @patch('ceph_volume.util.disk.is_locked_raw_device', lambda x: False) def test_is_ceph_rbd(self, patched_get_block_devs_sysfs, fake_filesystem): rbd_path = '/dev/rbd0' patched_get_block_devs_sysfs.return_value = [[rbd_path, rbd_path, 'disk']] result = disk.get_devices() assert rbd_path not in result - @patch('ceph_volume.util.disk.is_locked_raw_device', lambda x: False) def test_actuator_device(self, patched_get_block_devs_sysfs, fake_filesystem): sda_path = '/dev/sda' fake_actuator_nb = 2 |