]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: fix error 'KeyError' with inventory 44218/head
authorGuillaume Abrioux <gabrioux@redhat.com>
Mon, 6 Dec 2021 09:24:46 +0000 (10:24 +0100)
committerGuillaume Abrioux <gabrioux@redhat.com>
Tue, 7 Dec 2021 15:50:28 +0000 (16:50 +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>
src/ceph-volume/ceph_volume/api/lvm.py

index 174bdb8d52eaa332481ca65a66eda393913ca532..9a5907c5d7f994af3a6fc4460325ae03dde3aa42 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'],