]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: scan the system for lvs and vgs after zapping wip-bz1886534
authorAndrew Schoen <aschoen@redhat.com>
Fri, 9 Oct 2020 18:39:15 +0000 (13:39 -0500)
committerAndrew Schoen <aschoen@redhat.com>
Fri, 9 Oct 2020 18:39:15 +0000 (13:39 -0500)
Sometimes when `lvm zap` destroys an lv or vg the lvm cache
does not get updated and the deleted lv or vg will show up
as available. This runs `vgscan --cache` and `lvscan --cache`
to reset the that cache.

Resolves: rhbz#1886534

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
src/ceph-volume/ceph_volume/api/lvm.py
src/ceph-volume/ceph_volume/devices/lvm/zap.py

index 461e010506c2f92abce3223218e1a9164a084ec3..5e77ba5518bdfb6d1e076b7a1c89b7a0fda1aa25 100644 (file)
@@ -740,6 +740,18 @@ def get_device_vgs(device, name_prefix=''):
     return [VolumeGroup(**vg) for vg in vgs if vg['vg_name'] and vg['vg_name'].startswith(name_prefix)]
 
 
+def scan():
+    """
+    Scan the system for lvs and vgs. Sometimes
+    the cache can become stale when an lv or vg
+    is deleted. This will rescan the system
+    and ensure that `lvs` and `vgs` return
+    the actual state of the system.
+    """
+    process.run(['lvscan', '--cache'])
+    process.run(['vgscan', '--cache'])
+
+
 #################################
 #
 # Code for LVM Logical Volumes
index 21b54b6c0c419978bc5a9cfd6f8b3fbb41bb6087..e50d8055e719f216dd5b03540ed2204e2f12e74b 100644 (file)
@@ -188,6 +188,11 @@ class Zap(object):
                 mlogger.info('Removing LV because --destroy was given: %s',
                              device.abspath)
                 api.remove_lv(device.abspath)
+
+            # scan the system for lvs and vgs after deleting.
+            # this avoids and issue where stale lvm cache can
+            # show deleted lvs and vgs as available.
+            api.scan()
         elif lv:
             # just remove all lvm metadata, leaving the LV around
             lv.clear_tags()