summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lehman <dlehman@redhat.com>2010-02-12 14:23:04 -0600
committerDavid Lehman <dlehman@redhat.com>2010-02-15 19:17:43 -0600
commitb3337f7d91c5d193bcd2d354608e068ff5f6fc30 (patch)
treefbedebdc63a0faada95f4a80e1967150ea879a22
parentb7742bcc4408f4bd2f6a49d07c80e43093c2428c (diff)
downloadanaconda-b3337f7d91c5d193bcd2d354608e068ff5f6fc30.tar.gz
anaconda-b3337f7d91c5d193bcd2d354608e068ff5f6fc30.tar.xz
anaconda-b3337f7d91c5d193bcd2d354608e068ff5f6fc30.zip
Remove newly added partition from disk if subsequent commit fails. (#559907)
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.
-rw-r--r--storage/devices.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/storage/devices.py b/storage/devices.py
index 1132df284..eee43e204 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -1253,7 +1253,13 @@ class PartitionDevice(StorageDevice):
self.setupParents()
self.disk.format.addPartition(self.partedPartition)
- 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