From: Matthew Booth Date: Tue, 7 Nov 2023 19:58:16 +0000 (+0000) Subject: ceph-volume: fix raw list for non-existent device X-Git-Tag: v17.2.8~692^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F54430%2Fhead;p=ceph.git 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) (cherry picked from commit 0e17f8b5aebb51ee69ce0689dabe2a9111055716) --- diff --git a/src/ceph-volume/ceph_volume/devices/raw/list.py b/src/ceph-volume/ceph_volume/devices/raw/list.py index c86353b90ecc..dacd980fad60 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: