From 0e17f8b5aebb51ee69ce0689dabe2a9111055716 Mon Sep 17 00:00:00 2001 From: Matthew Booth Date: Tue, 7 Nov 2023 19:58:16 +0000 Subject: [PATCH] ceph-volume: fix raw list for non-existent device 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 (cherry picked from commit e009b1a319c834a504947423ae1dd55387809235) --- src/ceph-volume/ceph_volume/devices/raw/list.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ceph-volume/ceph_volume/devices/raw/list.py b/src/ceph-volume/ceph_volume/devices/raw/list.py index c86353b90ecc8..dacd980fad603 100644 --- a/src/ceph-volume/ceph_volume/devices/raw/list.py +++ b/src/ceph-volume/ceph_volume/devices/raw/list.py @@ -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: -- 2.39.5