Merge ~ogayot/curtin:wwn-match-with-extension into curtin:master

Proposed by Olivier Gayot
Status: Merged
Approved by: Dan Bungert
Approved revision: d4f445a3418af09f966c791461c55d94bd2ff668
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~ogayot/curtin:wwn-match-with-extension
Merge into: curtin:master
Diff against target: 42 lines (+19/-1)
2 files modified
curtin/commands/block_meta.py (+2/-1)
tests/unittests/test_commands_block_meta.py (+17/-0)
Reviewer Review Type Date Requested Status
Dan Bungert Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+440232@code.launchpad.net

Commit message

block-meta: fix failed disk lookup when WWN includes extension

curtin's storage config extracts the WWN of a disk from one of the
following udev variables:

 * ID_WWN_WITH_EXTENSION (preferred)
 * ID_WWN

However, when trying to look the disk up later in the block-meta code,
curtin only tries to match the WWN value against the ID_WWN variable
(and another variable related to DM multipath).

This means that the disk can not be be found just based on the wwn if
the ID_WWN and ID_WWN_WITH_EXTENSION variables don't hold the same
value.

In the past, that was often okay because other fields (such as disk path
or serial) would still make the disk lookup succeed.

However, the following patch introduced a restriction. In v2, all fields
specified must now match for the disk lookup to be successful:

8c5f87ed block_meta: all fields on a disk action must match with v2 config

Fixed by matching against the ID_WWN_WITH_EXTENSION (preferred) and then
ID_WWN.

Description of the change

We got multiple reports of failed installs where curtin logs show the following pattern:

found candidate disks [set(), {'/dev/sda'}, {'/dev/sda'}]
        An error occured handling 'disk-sda': ValueError - Failed to find storage volume id='disk-sda' config: {'ptable': 'gpt', 'serial': '121212121212121212121212', 'wwn': '0x123456789abcdef0deadbeef', 'path': '/dev/sda', 'wipe': 'superblock-recursive', 'preserve': False, 'name': '', 'grub_device': False, 'type': 'disk', 'id': 'disk-sda'}

When trying to look up the disk, the value of the wwn field (i.e., 0x123456789abcdef0deadbeef here) is compared to the ID_WWN udev variable of available disks.

However, the wwn variable is not always initialized from the ID_WWN variable. If present, the ID_WWN_WITH_EXTENSION variable takes precedence:

source_keys = {
                'wwn': ['ID_WWN_WITH_EXTENSION', 'ID_WWN'],
                'serial': ['ID_SERIAL', 'ID_SERIAL_SHORT'],
            }

Example
-------

"ID_WWN": '0x123456789abcdef0'
"ID_WWN_VENDOR_EXTENSION": "0xdeadbeef",
"ID_WWN_WITH_EXTENSION": '0x123456789abcdef0deadbeef'

Since present, the wwn variable gets initialized from ID_WWN_WITH_EXTENSION.

Later on, we compare the wwn variable with ID_WWN and the lookup fails.

Fixed by making sure to compare the wwn value with the ID_WWN_WITH_EXTENSION first (if available), and only then ID_WWN.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Olivier Gayot (ogayot) wrote :

Note: I'm quite confident that the patch will help but I don't have a way to reproduce the bug in a real install so we might need to lean on the users who originally reported the issue to test again and confirm.

Revision history for this message
Dan Bungert (dbungert) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py
2index c0e595d..7988f3a 100644
3--- a/curtin/commands/block_meta.py
4+++ b/curtin/commands/block_meta.py
5@@ -513,7 +513,8 @@ def v2_get_path_to_disk(vol):
6 cands.append(set([dev['DEVNAME'] for dev in new_devs]))
7
8 if 'wwn' in vol:
9- add_cands(*disk_by_keys(vol['wwn'], 'DM_WWN', 'ID_WWN'))
10+ add_cands(*disk_by_keys(vol['wwn'],
11+ 'DM_WWN', 'ID_WWN_WITH_EXTENSION', 'ID_WWN'))
12 if 'serial' in vol:
13 add_cands(
14 *disk_by_keys(
15diff --git a/tests/unittests/test_commands_block_meta.py b/tests/unittests/test_commands_block_meta.py
16index 0c198e6..82530ff 100644
17--- a/tests/unittests/test_commands_block_meta.py
18+++ b/tests/unittests/test_commands_block_meta.py
19@@ -222,6 +222,23 @@ class TestGetPathToStorageVolume(CiTestCase):
20 devname,
21 block_meta.get_path_to_storage_volume(disk_id, s_cfg))
22
23+ def test_v2_match_wwn_with_extension(self):
24+ wwn = self.random_string()
25+ extension = self.random_string()
26+ devname = self.random_string()
27+ self.m_udev_all.return_value = [
28+ {'DEVNAME': devname,
29+ 'ID_WWN': wwn,
30+ 'ID_WWN_WITH_EXTENSION': wwn + extension},
31+ ]
32+ disk_id = self.random_string()
33+ cfg = {'id': disk_id, 'type': 'disk', 'wwn': wwn + extension}
34+ s_cfg = OrderedDict({disk_id: cfg})
35+ s_cfg.version = 2
36+ self.assertEqual(
37+ devname,
38+ block_meta.get_path_to_storage_volume(disk_id, s_cfg))
39+
40 def test_v2_match_wwn_prefer_mpath(self):
41 wwn = self.random_string()
42 devname1 = self.random_string()

Subscribers

People subscribed via source and target branches