]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: fix error 'KeyError' with inventory 44884/head
authorGuillaume Abrioux <gabrioux@redhat.com>
Mon, 6 Dec 2021 09:24:46 +0000 (10:24 +0100)
committerGuillaume Abrioux <gabrioux@redhat.com>
Mon, 14 Feb 2022 14:37:39 +0000 (15:37 +0100)
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 <gabrioux@redhat.com>
(cherry picked from commit 691660c42eaa568a754670e093c512aa041d1479)

src/ceph-volume/ceph_volume/api/lvm.py

index de9717a3406be8b335b282418a4b598fd4f8e1fc..6b9185ed7a02171a26381e7059133b2673fc6265 100644 (file)
@@ -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'],