Merge ~ogayot/curtin:lunar-2023-04-03 into curtin:ubuntu/lunar

Proposed by Olivier Gayot
Status: Merged
Approved by: Dan Bungert
Approved revision: f30a1533f88b753b6fdd3c04699dda9621b632cc
Merged at revision: f30a1533f88b753b6fdd3c04699dda9621b632cc
Proposed branch: ~ogayot/curtin:lunar-2023-04-03
Merge into: curtin:ubuntu/lunar
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
Server Team CI bot continuous-integration Needs Fixing
Dan Bungert Approve
Review via email: mp+440267@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.

(cherry picked from commit 73da3c4f47ea22d58f57371594a396c5434ab260)

Description of the change

Cherry pick to ubuntu/lunar of the change introduced in https://code.launchpad.net/~ogayot/curtin/+git/curtin/+merge/440232.

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
Dan Bungert (dbungert) :
review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Dan Bungert (dbungert) wrote :

Confirmed that the autolander is trying to test with a merge to master, so a manual merge is desired.

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