[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 5/6] Return disk to prior state following failed partition removal. (#580088)



This returns the disk to the state it was in prior to the attempt
to remove the partition so we can try again after making sure all
lvm and md devices are stopped.
---
 storage/devices.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index c24f4cd..643a00f 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -1354,7 +1354,11 @@ class PartitionDevice(StorageDevice):
         # we should have already set self.partedPartition to point to the
         # partition on the original disklabel
         self.disk.originalFormat.removePartition(self.partedPartition)
-        self.disk.originalFormat.commit()
+        try:
+            self.disk.originalFormat.commit()
+        except DiskLabelCommitError:
+            self.disk.originalFormat.addPartition(self.partedPartition)
+            raise
 
         self.exists = False
 
-- 
1.6.6.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]