Comment 12 for bug 1925722

Revision history for this message
Ryan Harper (raharper) wrote :

> but later I found a way to deploy onto a physical server and I shared a
> log from it in my last comment.

Thanks; this is helpful.

'storage': {'config': [
    {'id': 'sda', 'model': 'PERC H700', 'name': 'sda',
      'serial': '6842b2b01b006d0024858f55183677de',
      'type': 'disk', 'wipe': 'superblock'},
    {'grub_device': True, 'id': 'sdb', 'model': 'MP0402H',
     'name': 'sdb', 'ptable': 'gpt', 'serial': '581270040222',
     'type': 'disk', 'wipe': 'superblock'},
...
]

Two disks identified, and required them to be wiped. Then the
dd-image will take the meta_simple path and sdb is selected as the
target (due to grub_device: True).

Then here's the bug:

'custom' mode but multiple devices given. using first found
2021-04-24T01:12:50-05:00 dell2 cloud-init[1606]: mode is 'custom'. multiple devices given. using '/dev/sda' (first available)

In the code, we example args.devices which was set to both disks
due to including both of them in the storage config for wiping.

The logic which looks through the list of devices when more than
one is supplied did not account for diskPath being set.

The cleanest fix here is to only select from the devices list if
devpath did not get set.

diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py
index cf6bc025..e2f37201 100644
--- a/curtin/commands/block_meta.py
+++ b/curtin/commands/block_meta.py
@@ -2007,17 +2007,20 @@ def meta_simple(args):
     elif len(devices) == 0 and devpath:
         devices = [devpath]

- if len(devices) > 1:
- if args.devices is not None:
- LOG.warn("'%s' mode but multiple devices given. "
- "using first found", args.mode)
- available = [f for f in devices
- if block.is_valid_device(f)]
- target = sorted(available)[0]
- LOG.warn("mode is '%s'. multiple devices given. using '%s' "
- "(first available)", args.mode, target)
+ if devpath is not None:
+ target = devpath
     else:
- target = devices[0]
+ if len(devices) > 1:
+ if args.devices is not None:
+ LOG.warn("'%s' mode but multiple devices given. "
+ "using first found", args.mode)
+ available = [f for f in devices
+ if block.is_valid_device(f)]
+ target = sorted(available)[0]
+ LOG.warn("mode is '%s'. multiple devices given. using '%s' "
+ "(first available)", args.mode, target)
+ else:
+ target = devices[0]