From: Guillaume Abrioux Date: Thu, 4 May 2023 08:08:09 +0000 (+0200) Subject: ceph-volume: fix a bug in `get_lvm_fast_allocs()` (batch) X-Git-Tag: v17.2.7~260^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3c06bc4c69389475f9d47bbb001669ba9e35aee6;p=ceph.git ceph-volume: fix a bug in `get_lvm_fast_allocs()` (batch) `get_lvm_fast_allocs()` in `devices/lvm/batch.py` calls the property `Device.used_by_ceph` in order to filter out devices that are already used by ceph. The issue is that `Device.used_by_ceph()` itself filters out journal devices (db/wal) given that a db/wal device can be shared between multiple OSDs. The consequence is that `Device.used_by_ceph()` always returns False for a db/wal device (even if it is actually already used by ceph) so `get_lvm_fast_allocs()` always returns the full list of the passed db/wal devices on the `lvm batch` CLI command. Finally, the logic in `devices.lvm.batch.get_deployment_layout()` checks whether the length of the list returned by `get_lvm_fast_allocs()` is equal to `num_osds` (the number of OSD being created), if not it fails. Fixes: https://tracker.ceph.com/issues/59640 Signed-off-by: Guillaume Abrioux (cherry picked from commit 8da98bf2ac8cf223904acd971f3a0342bdbd26f9) --- diff --git a/src/ceph-volume/ceph_volume/devices/lvm/batch.py b/src/ceph-volume/ceph_volume/devices/lvm/batch.py index 9ed2bf2fccf43..d867fe2d87e3b 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/batch.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/batch.py @@ -171,7 +171,7 @@ def group_devices_by_vg(devices): def get_lvm_fast_allocs(lvs): return [("{}/{}".format(d.vg_name, d.lv_name), 100.0, disk.Size(b=int(d.lvs[0].lv_size)), 1) for d in lvs if not - d.used_by_ceph] + d.journal_used_by_ceph] class Batch(object): diff --git a/src/ceph-volume/ceph_volume/util/device.py b/src/ceph-volume/ceph_volume/util/device.py index 015cfe6ff607c..c9324e7776c8a 100644 --- a/src/ceph-volume/ceph_volume/util/device.py +++ b/src/ceph-volume/ceph_volume/util/device.py @@ -524,6 +524,15 @@ class Device(object): if lv.tags.get("ceph.type") in ["data", "block"]] return any(osd_ids) + @property + def journal_used_by_ceph(self): + # similar to used_by_ceph() above. This is for 'journal' devices (db/wal/..) + # needed by get_lvm_fast_allocs() in devices/lvm/batch.py + # see https://tracker.ceph.com/issues/59640 + osd_ids = [lv.tags.get("ceph.osd_id") is not None for lv in self.lvs + if lv.tags.get("ceph.type") in ["db", "wal"]] + return any(osd_ids) + @property def vg_free_percent(self): if self.vgs: