Merge ~mwhudson/curtin:v2-remaining-fixes into curtin:master

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: 82e1b354a2671698973f7cc20d1d1a6511e2edf9
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~mwhudson/curtin:v2-remaining-fixes
Merge into: curtin:master
Diff against target: 82 lines (+24/-8)
3 files modified
curtin/block/deps.py (+6/-2)
curtin/commands/block_meta_v2.py (+18/-5)
tests/vmtests/__init__.py (+0/-1)
Reviewer Review Type Date Requested Status
Dan Bungert Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+415879@code.launchpad.net

Commit message

block_meta_v2: a few more fixes for v2 partitioning

With this and the other branches I have in review, at least some
vmtests pass when converted to v2 storage configs.

To post a comment you must log in.
~mwhudson/curtin:v2-remaining-fixes updated
82e1b35... by Michael Hudson-Doyle

remove offset from injected prep partition

as v2 partitioning respects offsets, this now causes failures

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/block/deps.py b/curtin/block/deps.py
2index 38581a8..db449d8 100644
3--- a/curtin/block/deps.py
4+++ b/curtin/block/deps.py
5@@ -96,8 +96,12 @@ def detect_required_packages_mapping(osfamily=DISTROS.debian):
6 if osfamily not in distro_mapping:
7 raise ValueError('No block package mapping for distro: %s' % osfamily)
8
9- return {1: {'handler': storage_config_required_packages,
10- 'mapping': distro_mapping.get(osfamily)}}
11+ cfg_map = {
12+ 'handler': storage_config_required_packages,
13+ 'mapping': distro_mapping.get(osfamily),
14+ }
15+
16+ return {1: cfg_map, 2: cfg_map}
17
18
19 # vi: ts=4 expandtab syntax=python
20diff --git a/curtin/commands/block_meta_v2.py b/curtin/commands/block_meta_v2.py
21index 772c347..c29f98d 100644
22--- a/curtin/commands/block_meta_v2.py
23+++ b/curtin/commands/block_meta_v2.py
24@@ -15,6 +15,7 @@ from curtin.log import LOG
25 from curtin.storage_config import (
26 GPT_GUID_TO_CURTIN_MAP,
27 )
28+from curtin.udev import udevadm_settle
29
30
31 @attr.s(auto_attribs=True)
32@@ -69,10 +70,16 @@ class SFDiskPartTable:
33 def apply(self, device):
34 sfdisk_script = self.render()
35 LOG.debug("sfdisk input:\n---\n%s\n---\n", sfdisk_script)
36- util.subp(
37- ['sfdisk', '--lock', '--no-tell', device],
38- data=sfdisk_script.encode('ascii'))
39- util.subp(['partprobe', device])
40+ util.subp(['sfdisk', device], data=sfdisk_script.encode('ascii'))
41+ # sfdisk (as invoked here) uses ioctls to inform the kernel that the
42+ # partition table has changed so it can add and remove device nodes for
43+ # the partitions as needed. Unfortunately this is asynchronous: sfdisk
44+ # can exit before the nodes are present in /dev (or /sys for that
45+ # matter). Calling "udevadm settle" is slightly incoherent as udev has
46+ # nothing to do with creating these nodes, but at the same time, udev
47+ # won't finish processing the events triggered by the sfdisk until
48+ # after the nodes for the partitions have been updated by the kernel.
49+ udevadm_settle()
50
51
52 class GPTPartTable(SFDiskPartTable):
53@@ -217,10 +224,16 @@ def disk_handler_v2(info, storage_config, handlers):
54 preserved_offsets = set()
55 wipes = {}
56
57- sfdisk_info = block.sfdisk_info(disk)
58+ sfdisk_info = None
59 for action in part_actions:
60 entry = table.add(action)
61 if action.get('preserve', False):
62+ if sfdisk_info is None:
63+ # Lazily computing sfdisk_info is slightly more efficient but
64+ # the real reason for doing this is that calling sfdisk_info on
65+ # a disk with no partition table logs messages that makes the
66+ # vmtest infrastructure unhappy.
67+ sfdisk_info = block.sfdisk_info(disk)
68 part_info = _find_part_info(sfdisk_info, entry.start)
69 partition_verify_sfdisk(action, sfdisk_info['label'], part_info)
70 preserved_offsets.add(entry.start)
71diff --git a/tests/vmtests/__init__.py b/tests/vmtests/__init__.py
72index fd6c246..60d7731 100644
73--- a/tests/vmtests/__init__.py
74+++ b/tests/vmtests/__init__.py
75@@ -2573,7 +2573,6 @@ def prep_partition_for_device(device):
76 'size': '8M',
77 'flag': 'prep',
78 'guid': '9e1a2d38-c612-4316-aa26-8b49521e5a8b',
79- 'offset': '1M',
80 'wipe': 'zero',
81 'grub_device': True,
82 'device': device}

Subscribers

People subscribed via source and target branches