Bug 846573 - cannot delete new partition
Summary: cannot delete new partition
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: python-blivet
Version: 17
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: David Lehman
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-08-08 07:21 UTC by Jan Safranek
Modified: 2013-08-01 17:01 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2013-08-01 17:01:05 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
reproducer script (961 bytes, text/x-python)
2012-08-08 07:21 UTC, Jan Safranek
no flags Details
Reproducer rebased to blivet 0.10 (980 bytes, text/x-python)
2013-04-12 11:23 UTC, Jan Safranek
no flags Details

Description Jan Safranek 2012-08-08 07:21:56 UTC
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

Comment 1 Jan Safranek 2012-08-08 07:33:26 UTC
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().

Comment 2 David Lehman 2012-11-16 15:48:22 UTC
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.

Comment 3 David Lehman 2013-02-05 23:16:46 UTC
This should be fixed by commit bd40ab4eec434a. You should probably be using DeviceTree.processActions instead of calling DeviceAction.execute directly.

Comment 4 Jan Safranek 2013-04-12 11:22:52 UTC
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

Comment 5 Jan Safranek 2013-04-12 11:23:53 UTC
Created attachment 734671 [details]
Reproducer rebased to blivet 0.10

Comment 6 Fedora End Of Life 2013-07-04 05:47:23 UTC
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.

Comment 7 Fedora End Of Life 2013-08-01 17:01:11 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.