From: Guillaume Abrioux Date: Wed, 19 Jul 2023 09:27:19 +0000 (+0000) Subject: python-common: drive_selection: fix KeyError when osdspec_affinity is not set X-Git-Tag: v16.2.14~1^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e952c9f11f5dbdc1fc7c81da31bdcc65a5aadb9d;p=ceph.git python-common: drive_selection: fix KeyError when osdspec_affinity is not set When osdspec_affinity is not set, the drive selection code will fail. This can happen when a device has multiple LVs where some of are used by Ceph and at least one LV isn't used by Ceph. Fixes: https://tracker.ceph.com/issues/58946 Signed-off-by: Guillaume Abrioux (cherry picked from commit 908f1d17a15a9d4c9bf603aa45e5f246bb0263e7) --- diff --git a/src/python-common/ceph/deployment/drive_selection/selector.py b/src/python-common/ceph/deployment/drive_selection/selector.py index d6556dd2c0a5..0753fe487382 100644 --- a/src/python-common/ceph/deployment/drive_selection/selector.py +++ b/src/python-common/ceph/deployment/drive_selection/selector.py @@ -131,9 +131,10 @@ class DriveSelection(object): if not disk.available and disk.ceph_device and disk.lvs: other_osdspec_affinity = '' for lv in disk.lvs: - if lv['osdspec_affinity'] != self.spec.service_id: - other_osdspec_affinity = lv['osdspec_affinity'] - break + if 'osdspec_affinity' in lv.keys(): + if lv['osdspec_affinity'] != self.spec.service_id: + other_osdspec_affinity = lv['osdspec_affinity'] + break if other_osdspec_affinity: logger.debug("{} is already used in spec {}, " "skipping it.".format(disk.path, other_osdspec_affinity))