]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: fix raw list for non-existent device 54430/head
authorMatthew Booth <mbooth@redhat.com>
Tue, 7 Nov 2023 19:58:16 +0000 (19:58 +0000)
committerGuillaume Abrioux <gabrioux@ibm.com>
Thu, 9 Nov 2023 08:03:39 +0000 (09:03 +0100)
ceph-volume should not crash when given a device which doesn't exist.

Fixes: https://tracker.ceph.com/issues/63391
Signed-off-by: Matthew Booth <mbooth@redhat.com>
(cherry picked from commit e009b1a319c834a504947423ae1dd55387809235)
(cherry picked from commit 0e17f8b5aebb51ee69ce0689dabe2a9111055716)

src/ceph-volume/ceph_volume/devices/raw/list.py

index c86353b90ecc8e97957b05f387d5a65070be2ef1..dacd980fad6036d9711a2e60d7feba0d45c23066 100644 (file)
@@ -88,7 +88,11 @@ class List(object):
             # parent isn't bluestore, then the child could be a valid bluestore OSD. If we fail to
             # determine whether a parent is bluestore, we should err on the side of not reporting
             # the child so as not to give a false negative.
-            info_device = [info for info in info_devices if info['NAME'] == dev][0]
+            matched_info_devices = [info for info in info_devices if info['NAME'] == dev]
+            if not matched_info_devices:
+                logger.warning('device {} does not exist'.format(dev))
+                continue
+            info_device = matched_info_devices[0]
             if 'PKNAME' in info_device and info_device['PKNAME'] != "":
                 parent = info_device['PKNAME']
                 try: