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

Re: [PATCH 2/2] Remove newly added partition from disk if subsequent commit fails. (#559907)


On 02/12/2010 09:28 PM, David Lehman wrote:
If the commit fails because there's an md array active on the disk
we will try again to add the partition after stopping the array, but
if we don't remove the failed-to-add partition first, we end up with
a mess.
  storage/devices.py |    8 +++++++-
  1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index 1132df2..eee43e2 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -1253,7 +1253,13 @@ class PartitionDevice(StorageDevice):

-            self.disk.format.commit()
+            try:
+                self.disk.format.commit()
+            except DiskLabelCommitError:
+                part = self.disk.format.partedDisk.getPartitionByPath(self.path)
+                self.disk.format.removePartition(part)
+                raise

              # Ensure old metadata which lived in freespace so did not get
              # explictly destroyed by a destroyformat action gets wiped

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