]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: fix partitions support in disk.get_devices()
authorGuillaume Abrioux <gabrioux@ibm.com>
Fri, 26 Jan 2024 20:35:18 +0000 (21:35 +0100)
committerGuillaume Abrioux <gabrioux@ibm.com>
Tue, 10 Sep 2024 20:06:21 +0000 (20:06 +0000)
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 <gabrioux@ibm.com>
(cherry picked from commit d5d2d1456542829495d3ebbbad6ca2febd7c344d)

src/ceph-volume/ceph_volume/util/device.py
src/ceph-volume/ceph_volume/util/disk.py

index 4911b3f9a46b14501d9aa4afbc9fbc41428be243..a7265784fa9317568cba32e24ea5c5c56acc75bb 100644 (file)
@@ -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()
index c77fd2cd74731b2603246ec3109e23db61500350..4c6e23992b196e3549a89ebab71607e916809f5c 100644 (file)
@@ -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):