Created attachment 602954 [details] reproducer script Description of problem: I use pyanaconda.storage as 'storage management library', i.e. outside of the installer. When I create a new partition and delete it (see attached reproducer), I get an exception: File "create-delete-partition.py", line 31, in <module> action.execute() File "/usr/lib64/python2.7/site-packages/pyanaconda/storage/deviceaction.py", line 286, in execute self.device.destroy() File "/usr/lib64/python2.7/site-packages/pyanaconda/storage/devices.py", line 831, in destroy self._destroy() File "/usr/lib64/python2.7/site-packages/pyanaconda/storage/devices.py", line 1559, in _destroy self.disk.originalFormat.removePartition(self.partedPartition) File "/usr/lib64/python2.7/site-packages/pyanaconda/storage/formats/disklabel.py", line 308, in removePartition self.partedDisk.removePartition(partition) File "/usr/lib64/python2.7/site-packages/parted/decorators.py", line 32, in new ret = fn(*args, **kwds) File "/usr/lib64/python2.7/site-packages/parted/disk.py", line 269, in removePartition if self.__disk.remove_partition(partition.getPedPartition()): _ped.PartitionException: Attempting to remove a partition that is not owned by any disk. I do not use the 'transaction mode', i.e. stack many action in device tree and commit them at once, I need small standalone actions. It works well most of the time, just partitions are a bit fragile, this PartitionException being the most problematic. Anaconda version: anaconda-17.29-1.fc17.x86_64
Everything works well if I try to remove already existing partition, i.e. partitions instantiated using storage.devicetree.populate() behave differently than the ones instantiated using storage.newPartition() & ActionCreateDevice(). With a little investigation, I have a _theory_. # delete the partition action = pyanaconda.storage.deviceaction.ActionDestroyDevice(part) storage.devicetree.registerAction(action) action.execute() action.execute() calls devicetree._removeDevice -> it calls part.disk.format.removePartition(part.partedPartition) action.execute() then calls part->destroy() -> it calls again part.disk.format.removePartition(part.partedPartition) -> traceback I have no idea why this sequence works for already existing partitions instantiated during devicetree.populate().
You are calling DiskLabel.resetPartedDisk, whose job is to reset the parted.Disk to match what was on the disk when the DiskLabel was instantiated. That means you are ripping the new partition you have created out from under anaconda. Obviously the code was not written to be used this way. The easiest workaround for you would be to instantiate a new DiskLabel after you execute each partition add/remove/resize so that when you call resetPartedDisk you are resetting it to the state you just established. In the longer term I can add some sort of reset method to DiskLabel to do the same thing.
This should be fixed by commit bd40ab4eec434a. You should probably be using DeviceTree.processActions instead of calling DeviceAction.execute directly.
Tested with python-blivet-0.10: b = blivet.Blivet() b.reset() # create new partition on /dev/sda disk = b.devicetree.getDeviceByName('sda') part = b.newPartition(parents=[disk], size=100, grow=False) action = blivet.deviceaction.ActionCreateDevice(part) b.devicetree.registerAction(action) blivet.partitioning.doPartitioning(storage=b) b.devicetree.processActions() # delete the partition part=b.devicetree.getDeviceByName('sda1') action = blivet.deviceaction.ActionDestroyDevice(part) b.devicetree.registerAction(action) b.devicetree.processActions() Traceback (most recent call last): File "../../download/create-delete-partition.py", line 34, in <module> b.devicetree.processActions() File "/usr/lib/python2.7/site-packages/blivet/devicetree.py", line 237, in processActions action.execute() File "/usr/lib/python2.7/site-packages/blivet/deviceaction.py", line 318, in execute self.device.destroy() File "/usr/lib/python2.7/site-packages/blivet/devices.py", line 821, in destroy self._destroy() File "/usr/lib/python2.7/site-packages/blivet/devices.py", line 1559, in _destroy self.disk.format.removePartition(part) File "/usr/lib/python2.7/site-packages/blivet/formats/disklabel.py", line 328, in removePartition self.partedDisk.removePartition(partition) File "/usr/lib64/python2.7/site-packages/parted/decorators.py", line 32, in new ret = fn(*args, **kwds) File "/usr/lib64/python2.7/site-packages/parted/disk.py", line 267, in removePartition raise parted.DiskException, "no partition specified" _ped.DiskException: no partition specified
Created attachment 734671 [details] Reproducer rebased to blivet 0.10
This message is a reminder that Fedora 17 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 17. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as WONTFIX if it remains open with a Fedora 'version' of '17'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version prior to Fedora 17's end of life. Bug Reporter: Thank you for reporting this issue and we are sorry that we may not be able to fix it before Fedora 17 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior to Fedora 17's end of life. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
Fedora 17 changed to end-of-life (EOL) status on 2013-07-30. Fedora 17 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora please feel free to reopen this bug against that version. Thank you for reporting this bug and we are sorry it could not be fixed.