From: Guillaume Abrioux Date: Fri, 26 Jan 2024 20:35:18 +0000 (+0100) Subject: ceph-volume: fix partitions support in disk.get_devices() X-Git-Tag: v17.2.8~91^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=24909507c0d98fda591eac7067721f94c779a422;p=ceph.git ceph-volume: fix partitions support in disk.get_devices() The following: ``` is_part = get_file_contents(os.path.join(_sys_dev_block_path, item, 'partition')) == "1" ``` assumes any `/sys/dev/block/x:y/partition` contains '1' which is wrong. This file actually contains the corresponding partition number. Fixes: https://tracker.ceph.com/issues/64195 Signed-off-by: Guillaume Abrioux (cherry picked from commit d5d2d1456542829495d3ebbbad6ca2febd7c344d) --- diff --git a/src/ceph-volume/ceph_volume/util/device.py b/src/ceph-volume/ceph_volume/util/device.py index 4911b3f9a46b1..a7265784fa931 100644 --- a/src/ceph-volume/ceph_volume/util/device.py +++ b/src/ceph-volume/ceph_volume/util/device.py @@ -137,7 +137,8 @@ class Device(object): self._is_lvm_member = None self.ceph_device = False self._parse() - self.device_nodes = sys_info.devices[self.path]['device_nodes'] + if self.path in sys_info.devices.keys(): + self.device_nodes = sys_info.devices[self.path]['device_nodes'] self.lsm_data = self.fetch_lsm(with_lsm) self.available_lvm, self.rejected_reasons_lvm = self._check_lvm_reject_reasons() diff --git a/src/ceph-volume/ceph_volume/util/disk.py b/src/ceph-volume/ceph_volume/util/disk.py index c77fd2cd74731..4c6e23992b196 100644 --- a/src/ceph-volume/ceph_volume/util/disk.py +++ b/src/ceph-volume/ceph_volume/util/disk.py @@ -839,6 +839,7 @@ def get_devices(_sys_block_path='/sys/block', device=''): sysdir = os.path.join(_sys_block_path, devname) if block[2] == 'part': sysdir = os.path.join(_sys_block_path, block[3], devname) + metadata = {} # If the device is ceph rbd it gets excluded if is_ceph_rbd(diskname):