From: Guillaume Abrioux Date: Mon, 6 Dec 2021 09:24:46 +0000 (+0100) Subject: ceph-volume: fix error 'KeyError' with inventory X-Git-Tag: v17.1.0~254^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F44218%2Fhead;p=ceph.git ceph-volume: fix error 'KeyError' with inventory The tag ceph.cluster_name is always set at the end. The only way it could be absent was if the osd prepare has been interrupted between [1] and [2]. [1] https://github.com/ceph/ceph/blob/v14.2.11/src/ceph-volume/ceph_volume/devices/lvm/strategies/bluestore.py#L355-L387 [2] https://github.com/ceph/ceph/blob/v14.2.11/src/ceph-volume/ceph_volume/devices/lvm/prepare.py Although the code received tremendous changes meantime and this error shouldn't show up again, we need to handle the case where this tag wouldn't have been set. Fixes: https://tracker.ceph.com/issues/44356 Signed-off-by: Guillaume Abrioux --- diff --git a/src/ceph-volume/ceph_volume/api/lvm.py b/src/ceph-volume/ceph_volume/api/lvm.py index 174bdb8d52ea..9a5907c5d7f9 100644 --- a/src/ceph-volume/ceph_volume/api/lvm.py +++ b/src/ceph-volume/ceph_volume/api/lvm.py @@ -8,7 +8,7 @@ import os import uuid from itertools import repeat from math import floor -from ceph_volume import process, util +from ceph_volume import process, util, conf from ceph_volume.exceptions import SizeAllocationError logger = logging.getLogger(__name__) @@ -839,7 +839,7 @@ class Volume(object): report = { 'name': self.lv_name, 'osd_id': self.tags['ceph.osd_id'], - 'cluster_name': self.tags['ceph.cluster_name'], + 'cluster_name': self.tags.get('ceph.cluster_name', conf.cluster), 'type': type_, 'osd_fsid': self.tags['ceph.osd_fsid'], 'cluster_fsid': self.tags['ceph.cluster_fsid'],