]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: fix a bug in lsblk_all() 49869/head
authorGuillaume Abrioux <gabrioux@redhat.com>
Thu, 1 Dec 2022 08:49:21 +0000 (09:49 +0100)
committerGuillaume Abrioux <gabrioux@redhat.com>
Wed, 25 Jan 2023 13:02:26 +0000 (14:02 +0100)
Rook has a specific use case where devices are copied in /mnt

If the basename (in /mnt) is different from the original device name,
then the current logic can't match it.

The idea is to append the device to the `lsblk` command and return
the result.

Fixes: https://tracker.ceph.com/issues/58137
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit dce4d469f66124babe97dd3651f67d55e805088c)

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

index 4a310e30f3d5cf6a5defb08cacad87f417587b5a..09db425e00ae838a9aa0594c632cf59910e70ade 100644 (file)
@@ -238,9 +238,13 @@ def _udevadm_info(device):
 
 
 def lsblk(device, columns=None, abspath=False):
-    return lsblk_all(device=device,
-                     columns=columns,
-                     abspath=abspath)
+    result = lsblk_all(device=device,
+                       columns=columns,
+                       abspath=abspath)
+    if not result:
+        raise RuntimeError(f"{device} not found is lsblk report")
+
+    return result[0]
 
 def lsblk_all(device='', columns=None, abspath=False):
     """
@@ -320,6 +324,9 @@ def lsblk_all(device='', columns=None, abspath=False):
         base_command.append('-p')
     base_command.append('-o')
     base_command.append(','.join(columns))
+    if device:
+        base_command.append('--nodeps')
+        base_command.append(device)
 
     out, err, rc = process.call(base_command)
 
@@ -331,14 +338,8 @@ def lsblk_all(device='', columns=None, abspath=False):
     for line in out:
         result.append(_lsblk_parser(line))
 
-    if not device:
-        return result
-
-    for dev in result:
-        if dev['NAME'] == os.path.basename(device):
-            return dev
+    return result
 
-    return {}
 
 def is_device(dev):
     """