From 735ed0b7d9cca5289365cefc8c3afd4bda2d1f16 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Wed, 29 Mar 2023 16:58:11 +0200 Subject: [PATCH] ceph-volume: quick fix in zap.py `api.get_single_pv(filters={'lv_uuid': lv.lv_uuid})` needs to be called only if `--destroy` is passed in order to remove vg and pv when there's nothing left. With old deployments, it is possible that a lv_uuid matches more than 1 PV. Given that `get_single_pv()` is only needed when `--destroy` is passed, let's move this call where it is actually needed. This makes `ceph-volume lvm zap` fail even though Fixes: https://tracker.ceph.com/issues/59210 Signed-off-by: Guillaume Abrioux (cherry picked from commit a666f700f16937565484dffc90713f6c04d76313) --- src/ceph-volume/ceph_volume/devices/lvm/zap.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ceph-volume/ceph_volume/devices/lvm/zap.py b/src/ceph-volume/ceph_volume/devices/lvm/zap.py index d6d778d165efe..708716e5e37a2 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/zap.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/zap.py @@ -168,7 +168,6 @@ class Zap(object): """ lv = api.get_single_lv(filters={'lv_name': device.lv_name, 'vg_name': device.vg_name}) - pv = api.get_single_pv(filters={'lv_uuid': lv.lv_uuid}) self.unmount_lv(lv) wipefs(device.path) @@ -182,8 +181,10 @@ class Zap(object): elif len(lvs) <= 1: mlogger.info('Only 1 LV left in VG, will proceed to destroy ' 'volume group %s', device.vg_name) + pvs = api.get_pvs(filters={'lv_uuid': lv.lv_uuid}) api.remove_vg(device.vg_name) - api.remove_pv(pv.pv_name) + for pv in pvs: + api.remove_pv(pv.pv_name) else: mlogger.info('More than 1 LV left in VG, will proceed to ' 'destroy LV only') -- 2.39.5