Blob Blame History Raw
From 6a62a81d326a1121a2768735e52a8e1c5e5d6f0d Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 24 Jun 2020 14:43:47 +0200
Subject: [PATCH] Add extra sleep after pvremove call

To give enough time for the async pvscan to finish scanning the
partition before removing it.

Resolves: rhbz#1640601
---
 blivet/formats/lvmpv.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/blivet/formats/lvmpv.py b/blivet/formats/lvmpv.py
index e4182adb..9f53ec6b 100644
--- a/blivet/formats/lvmpv.py
+++ b/blivet/formats/lvmpv.py
@@ -26,6 +26,7 @@ gi.require_version("BlockDev", "2.0")
 from gi.repository import BlockDev as blockdev
 
 import os
+import time
 
 from ..storage_log import log_method_call
 from parted import PARTITION_LVM
@@ -137,6 +138,9 @@ class LVMPhysicalVolume(DeviceFormat):
             DeviceFormat._destroy(self, **kwargs)
         finally:
             udev.settle()
+            # LVM now has async pvscan jobs so udev.settle doesn't help and if we try to remove
+            # the partition immediately after the pvremove we get an error
+            time.sleep(5)
 
     @property
     def destroyable(self):
-- 
2.25.4