Skip to content

Commit 0e17f8b

Browse files
mdboothguits
authored andcommitted
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 <[email protected]> (cherry picked from commit e009b1a)
1 parent 916a22e commit 0e17f8b

File tree

1 file changed

+5
-1
lines changed
  • src/ceph-volume/ceph_volume/devices/raw

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ def generate(self, devs=None):
8888
# parent isn't bluestore, then the child could be a valid bluestore OSD. If we fail to
8989
# determine whether a parent is bluestore, we should err on the side of not reporting
9090
# the child so as not to give a false negative.
91-
info_device = [info for info in info_devices if info['NAME'] == dev][0]
91+
matched_info_devices = [info for info in info_devices if info['NAME'] == dev]
92+
if not matched_info_devices:
93+
logger.warning('device {} does not exist'.format(dev))
94+
continue
95+
info_device = matched_info_devices[0]
9296
if 'PKNAME' in info_device and info_device['PKNAME'] != "":
9397
parent = info_device['PKNAME']
9498
try:

0 commit comments

Comments
 (0)