Bug 1156058

Summary: Not possible to replace existing disklabel with btrfs
Product: [Fedora] Fedora Reporter: Vojtech Trefny <vtrefny>
Component: python-blivetAssignee: David Lehman <dlehman>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: amulhern, anaconda-maint-list, bcl, dlehman, vpodzime
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: anaconda-21.48.14-1.fc21 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-11-15 09:16:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
patch
none
proposed patch none

Description Vojtech Trefny 2014-10-23 13:47:57 UTC
Created attachment 949889 [details]
patch

Description of problem:

I'm trying to replace existing disklabel with btrfs using this simple script -- https://gist.github.com/vojtechtrefny/bced01f67717fd564d9b (sdc is existing disk with existing msdos disklabel without any partitions).

Blivet fails, because there are "partitions in use" on this disk:

------------------------------------------
Traceback (most recent call last):
  File "replace-disklabel-btrfs.py", line 21, in <module>
    b.doIt()
  File "/usr/lib/python2.7/site-packages/blivet/__init__.py", line 355, in doIt
    self.devicetree.processActions(callbacks)
  File "/usr/lib/python2.7/site-packages/blivet/devicetree.py", line 354, in processActions
    self._preProcessActions()
  File "/usr/lib/python2.7/site-packages/blivet/devicetree.py", line 258, in _preProcessActions
    ",".join(problematic))
RuntimeError: partitions in use on disks with changes pending: btrfs
------------------------------------------

The problem is the newly created (still non-existing) btrfs volume has its status set to True -- status of BTRFSDevice is based on its parents statuses (in this case on sdc.status) which is True, because statuses of disks is based only on its existence and os.access.
Because of its status, the _preProcessActions function considers it as "active" and won't allow to delete the disklabel on disk with active device.

Attached patch sets status for non-existing BTRFSDevice with only "disk parents" to False.

Comment 1 David Lehman 2014-10-23 17:58:02 UTC
Created attachment 950041 [details]
proposed patch

Status is only relevant for existing devices. This patch should do the trick. Thanks for reporting it.

Comment 2 Fedora Update System 2014-11-11 21:09:40 UTC
anaconda-21.48.14-1.fc21, python-blivet-0.61.9-1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/python-blivet-0.61.9-1.fc21,anaconda-21.48.14-1.fc21

Comment 3 Fedora Update System 2014-11-13 18:17:05 UTC
Package anaconda-21.48.14-1.fc21, python-blivet-0.61.9-1.fc21:
* should fix your issue,
* was pushed to the Fedora 21 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing anaconda-21.48.14-1.fc21 python-blivet-0.61.9-1.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-14928/python-blivet-0.61.9-1.fc21,anaconda-21.48.14-1.fc21
then log in and leave karma (feedback).

Comment 4 Fedora Update System 2014-11-15 09:16:12 UTC
anaconda-21.48.14-1.fc21, python-blivet-0.61.9-1.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.