From cd5360736d217cedb80fed6538749508b240b236 Mon Sep 17 00:00:00 2001 From: David Ames Date: Wed, 15 May 2019 10:58:18 -0700 Subject: [PATCH] Validate output of list_logical_volumes The charm was checking for the zeroth value of the return value of list_logical_volumes. However, if no logical volumes are found it returns an empty list. This change validates that the list has an entry. Change-Id: I75a6b1dda15dd7c2cece8cfe97b28317b3d5162b Partial-Bug: #1819382 --- ceph/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ceph/utils.py b/ceph/utils.py index 05f581e..972f1ad 100644 --- a/ceph/utils.py +++ b/ceph/utils.py @@ -1692,7 +1692,10 @@ def is_active_bluestore_device(dev): return False vg_name = lvm.list_lvm_volume_group(dev) - lv_name = lvm.list_logical_volumes('vg_name={}'.format(vg_name))[0] + try: + lv_name = lvm.list_logical_volumes('vg_name={}'.format(vg_name))[0] + except IndexError: + return False block_symlinks = glob.glob('/var/lib/ceph/osd/ceph-*/block') for block_candidate in block_symlinks: