curtin block-meta selects first entry in unordered list

Bug #1244026 reported by Scott Moser
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Cloud Archive
Fix Released
High
Unassigned
curtin
Fix Released
High
Unassigned
curtin (Ubuntu)
Fix Released
High
Unassigned
Saucy
Fix Released
High
Unassigned

Bug Description

== Begin SRU Info ==
[Description]
Very stupidly, curtin obtained a list of unused devices in a dict where the key was the device shortname, and then selected the first device in that list to install to:
 devices = {'sda': {'entry1': 'value1'}, 'sdb': {'entry2': 'value2'}}
 selected = [f for f in devices][0]

The problem there is that the dict is not sorted.
The solution to correctly implement this simplistic heuristic is:
 devices = {'sda': {'entry1': 'value1'}, 'sdb': {'entry2': 'value2'}}
 selected = sorted([f for f in devices])[0]

[Impact]
By default, installs via curtin to a system with more than one disk were not reliably selecting the first disk for installation as intended. Selecting the wrong disk resulted in system not booting on reboot after installation.

[Test Case]
Deploy a system with curtin via MAAS and see it fail because it installs to /dev/sdd or /dev/sde (in the case there were 4 or 5 disks).

After fix, the install will be done to /dev/sda.

[Regression Potential]
Very low. curtin would correctly install the target device only randomly with the chance going down with each additional disk on the system. This correctly implements the simplistic behavior of "pick the first available device".

== End SRU Info ==

curtin block-meta gets a list of unused devices as a dict.
turns the dict to a list
and then takes [0]

but that is unsorted.

=== modified file 'curtin/commands/block_meta.py'
--- curtin/commands/block_meta.py 2013-09-17 00:46:22 +0000
+++ curtin/commands/block_meta.py 2013-10-24 03:07:37 +0000
@@ -57,7 +57,7 @@
                      "using first found")
         available = [f for f in devices
                      if block.is_valid_device(f)]
- target = available[0]
+ target = sorted(available)[0]
         LOG.warn("mode is 'simple'. multiple devices given. using '%s' "
                  "(first available)", target)
     else:

Scott Moser (smoser)
Changed in curtin:
status: New → Confirmed
Changed in cloud-archive:
status: New → Confirmed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package curtin - 0.1.0~bzr95-0ubuntu1

---------------
curtin (0.1.0~bzr95-0ubuntu1) trusty; urgency=low

  * New upstream snapshot.
    * fix bug in block-meta resulting in first disk not always being used
       (LP: #1244026)
 -- Scott Moser <email address hidden> Thu, 24 Oct 2013 01:41:47 -0400

Changed in curtin (Ubuntu):
status: New → Fix Released
Scott Moser (smoser)
Changed in curtin (Ubuntu Saucy):
status: New → In Progress
Scott Moser (smoser)
description: updated
Revision history for this message
Adam Conrad (adconrad) wrote : Please test proposed package

Hello Scott, or anyone else affected,

Accepted curtin into saucy-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/curtin/0.1.0~bzr94-0ubuntu1.13.10.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in curtin (Ubuntu Saucy):
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
Scott Moser (smoser) wrote :

fixed in trunk at revno 95.

Changed in cloud-archive:
status: Confirmed → In Progress
status: In Progress → Fix Committed
Changed in curtin:
status: Confirmed → Fix Committed
Revision history for this message
Scott Moser (smoser) wrote :

verification-done: we've successfully run installation on the systems that were previously showing the error.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package curtin - 0.1.0~bzr94-0ubuntu1.13.10.1

---------------
curtin (0.1.0~bzr94-0ubuntu1.13.10.1) saucy-proposed; urgency=low

  * New upstream snapshot.
    * fix bug in block-meta resulting in first disk not always being used
       (LP: #1244026)
 -- Scott Moser <email address hidden> Thu, 24 Oct 2013 09:00:23 -0700

Changed in curtin (Ubuntu Saucy):
status: Fix Committed → Fix Released
Revision history for this message
Scott Kitterman (kitterman) wrote : Update Released

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

Scott Moser (smoser)
Changed in curtin:
importance: Undecided → High
Changed in cloud-archive:
importance: Undecided → High
Changed in curtin (Ubuntu):
importance: Undecided → High
Changed in curtin (Ubuntu Saucy):
importance: Undecided → High
Changed in curtin:
status: Fix Committed → Fix Released
Changed in cloud-archive:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.