[Bug 1244026] Re: curtin block-meta selects first entry in unordered list

Corey Bryant corey.bryant at canonical.com
Thu Nov 5 14:56:08 UTC 2015


** Changed in: curtin
       Status: Fix Committed => Fix Released

** Changed in: cloud-archive
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of Ubuntu
OpenStack, which is subscribed to Ubuntu Cloud Archive.
https://bugs.launchpad.net/bugs/1244026

Title:
  curtin block-meta selects first entry in unordered list

Status in Ubuntu Cloud Archive:
  Fix Released
Status in curtin:
  Fix Released
Status in curtin package in Ubuntu:
  Fix Released
Status in curtin source package in Saucy:
  Fix Released

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:

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-archive/+bug/1244026/+subscriptions



More information about the Ubuntu-openstack-bugs mailing list