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

Proposed by Michael Hudson-Doyle
Status: Rejected
Rejected by: Michael Hudson-Doyle
Proposed branch: ~mwhudson/curtin:v2-fixes
Merge into: curtin:master
Diff against target: 259 lines (+77/-39)
5 files modified
curtin/block/deps.py (+6/-2)
curtin/commands/block_meta_v2.py (+22/-14)
tests/integration/test_block_meta.py (+6/-3)
tests/vmtests/__init__.py (+28/-20)
tests/vmtests/test_basic.py (+15/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Needs Fixing
curtin developers Pending
Review via email: mp+415779@code.launchpad.net

Description of the change

I don't expect to commit this as is, but I do want to see how it does in CI.

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:3924a3d671b242b20c95ebd266d56f189a67833c

No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want jenkins to rebuild you need to trigger it yourself):
https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/415779/+edit-commit-message

https://jenkins.ubuntu.com/server/job/curtin-ci/244/
Executed test runs:
    FAILURE: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-amd64/244/
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-arm64/244/
    FAILURE: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-ppc64el/244/
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-s390x/244/

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/curtin-ci/244//rebuild

review: Needs Fixing (continuous-integration)
~mwhudson/curtin:v2-fixes updated
f525099... by Michael Hudson-Doyle

lazily call sfdisk_info

because calling sfdisk_info when there is no partition table makes the vmtests fail

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

The vmtests pass now for me -- mostly. There is definitely a race or two lurking.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:f52509936f29c993f47900dcfa4ca52682d260cd

No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want jenkins to rebuild you need to trigger it yourself):
https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/415779/+edit-commit-message

https://jenkins.ubuntu.com/server/job/curtin-ci/245/
Executed test runs:
    FAILURE: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-amd64/245/
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-arm64/245/
    FAILURE: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-ppc64el/245/
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-s390x/245/

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/curtin-ci/245//rebuild

review: Needs Fixing (continuous-integration)
~mwhudson/curtin:v2-fixes updated
a9a241a... by Michael Hudson-Doyle

debugging by printing

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:a9a241a3e5d127fccdd68ed6135bf360fd3bffe0

No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want jenkins to rebuild you need to trigger it yourself):
https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/415779/+edit-commit-message

https://jenkins.ubuntu.com/server/job/curtin-ci/246/
Executed test runs:
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-amd64/246/
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-arm64/246/
    FAILURE: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-ppc64el/246/
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-s390x/246/

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/curtin-ci/246//rebuild

review: Needs Fixing (continuous-integration)
~mwhudson/curtin:v2-fixes updated
127ddf6... by Michael Hudson-Doyle

what

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:127ddf64bcbabbd1fc17d2073090e75965eea52b

No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want jenkins to rebuild you need to trigger it yourself):
https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/415779/+edit-commit-message

https://jenkins.ubuntu.com/server/job/curtin-ci/247/
Executed test runs:
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-amd64/247/
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-arm64/247/
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-ppc64el/247/
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-s390x/247/

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/curtin-ci/247//rebuild

review: Needs Fixing (continuous-integration)
~mwhudson/curtin:v2-fixes updated
79b2d7c... by Michael Hudson-Doyle

write a small novel about why we call udevadm settle here

767c011... by Michael Hudson-Doyle

refactor things to allow a test case to override storage config version, add some v2 tests

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:767c01129935de2630367b0baca328015913d9ec

No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want jenkins to rebuild you need to trigger it yourself):
https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/415779/+edit-commit-message

https://jenkins.ubuntu.com/server/job/curtin-ci/248/
Executed test runs:
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-amd64/248/
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-arm64/248/
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-ppc64el/248/
    SUCCESS: https://jenkins.ubuntu.com/server/job/curtin-ci/nodes=metal-s390x/248/

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/curtin-ci/248//rebuild

review: Needs Fixing (continuous-integration)

Unmerged commits

767c011... by Michael Hudson-Doyle

refactor things to allow a test case to override storage config version, add some v2 tests

79b2d7c... by Michael Hudson-Doyle

write a small novel about why we call udevadm settle here

127ddf6... by Michael Hudson-Doyle

what

a9a241a... by Michael Hudson-Doyle

debugging by printing

f525099... by Michael Hudson-Doyle

lazily call sfdisk_info

because calling sfdisk_info when there is no partition table makes the vmtests fail

3924a3d... by Michael Hudson-Doyle

convert examples/tests/basic.yaml to v2

and some fixes to make it work

49c35be... by Michael Hudson-Doyle

block_meta_v2: fix implicit offset calculation for dos partitions

5e46883... by Michael Hudson-Doyle

block_meta_v2: do not use aliases for partition types

These are not supported by sfdisk in focal.

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..a2a0708 100644
22--- a/curtin/commands/block_meta_v2.py
23+++ b/curtin/commands/block_meta_v2.py
24@@ -5,6 +5,7 @@ from typing import Optional
25 import attr
26
27 from curtin import (block, util)
28+from curtin.udev import udevadm_settle
29 from curtin.commands.block_meta import (
30 disk_handler as disk_handler_v1,
31 get_path_to_storage_volume,
32@@ -53,6 +54,11 @@ def align_down(size, block_size):
33 FLAG_TO_GUID = {
34 flag: guid for (guid, (flag, typecode)) in GPT_GUID_TO_CURTIN_MAP.items()
35 }
36+FLAG_TO_MBR_TYPE = {
37+ flag: typecode[:2].upper() for (guid, (flag, typecode))
38+ in GPT_GUID_TO_CURTIN_MAP.items()
39+ }
40+FLAG_TO_MBR_TYPE['extended'] = '05'
41
42
43 class SFDiskPartTable:
44@@ -69,10 +75,16 @@ class SFDiskPartTable:
45 def apply(self, device):
46 sfdisk_script = self.render()
47 LOG.debug("sfdisk input:\n---\n%s\n---\n", sfdisk_script)
48- util.subp(
49- ['sfdisk', '--lock', '--no-tell', device],
50- data=sfdisk_script.encode('ascii'))
51- util.subp(['partprobe', device])
52+ util.subp(['sfdisk', device], data=sfdisk_script.encode('ascii'))
53+ # sfdisk (as invoked here) uses ioctls to inform the kernel that the
54+ # partition table has changed so it can add and remove device nodes for
55+ # the partitions as needed. Unfortunately this is asynchronous: sfdisk
56+ # can exit before the nodes are present in /dev (or /sys for that
57+ # matter). Calling "udevadm settle" is slightly incoherent as udev has
58+ # nothing to do with creating these nodes, but at the same time, udev
59+ # won't finish processing the events triggered by the sfdisk until
60+ # after the nodes for the partitions have been updated by the kernel.
61+ udevadm_settle()
62
63
64 class GPTPartTable(SFDiskPartTable):
65@@ -144,20 +156,12 @@ class DOSPartTable(SFDiskPartTable):
66 for entry in self.entries:
67 if entry.number <= 4:
68 prev = entry
69- break
70 if prev is None:
71 start = ONE_MIB_SECTORS
72 else:
73 start = align_up(prev.start + prev.size, ONE_MIB_SECTORS)
74 size = int(util.human2bytes(action['size'])) // SECTOR_BYTES
75- FLAG_TO_TYPE = {
76- 'extended': 'extended',
77- 'boot': 'uefi',
78- 'swap': 'swap',
79- 'lvm': 'lvm',
80- 'raid': 'raid',
81- }
82- type = FLAG_TO_TYPE.get(flag)
83+ type = FLAG_TO_MBR_TYPE.get(flag)
84 if flag == 'boot':
85 bootable = True
86 else:
87@@ -217,10 +221,14 @@ def disk_handler_v2(info, storage_config, handlers):
88 preserved_offsets = set()
89 wipes = {}
90
91- sfdisk_info = block.sfdisk_info(disk)
92+ sfdisk_info = None
93 for action in part_actions:
94+ LOG.debug('processing partition action %s', action)
95 entry = table.add(action)
96+ LOG.debug('made entry %s', entry)
97 if action.get('preserve', False):
98+ if sfdisk_info is None:
99+ sfdisk_info = block.sfdisk_info(disk)
100 part_info = _find_part_info(sfdisk_info, entry.start)
101 partition_verify_sfdisk(action, sfdisk_info['label'], part_info)
102 preserved_offsets.add(entry.start)
103diff --git a/tests/integration/test_block_meta.py b/tests/integration/test_block_meta.py
104index fd119c5..a415c20 100644
105--- a/tests/integration/test_block_meta.py
106+++ b/tests/integration/test_block_meta.py
107@@ -116,19 +116,22 @@ class TestBlockMeta(IntegrationTestCase):
108 psize = 40 << 20
109 img = self.tmp_path('image.img')
110 config = StorageConfigBuilder(version=version)
111- config.add_image(path=img, size='100M', ptable=ptable)
112+ config.add_image(path=img, size='200M', ptable=ptable)
113 p1 = config.add_part(size=psize, number=1)
114 p2 = config.add_part(size=psize, number=2)
115+ p3 = config.add_part(size=psize, number=3)
116 self.run_bm(config.render())
117
118 with loop_dev(img) as dev:
119 self.assertEqual(
120 summarize_partitions(dev), [
121- PartData(number=1, offset=1 << 20, size=psize),
122- PartData(number=2, offset=(1 << 20) + psize, size=psize),
123+ PartData(number=1, offset=1 << 20, size=psize),
124+ PartData(number=2, offset=(1 << 20) + psize, size=psize),
125+ PartData(number=3, offset=(1 << 20) + 2*psize, size=psize),
126 ])
127 p1['offset'] = 1 << 20
128 p2['offset'] = (1 << 20) + psize
129+ p3['offset'] = (1 << 20) + 2*psize
130 config.set_preserve()
131 self.run_bm(config.render())
132
133diff --git a/tests/vmtests/__init__.py b/tests/vmtests/__init__.py
134index fd6c246..c83e60e 100644
135--- a/tests/vmtests/__init__.py
136+++ b/tests/vmtests/__init__.py
137@@ -630,6 +630,7 @@ class VMBaseClass(TestCase):
138 '/MAAS/api/version/': '2.0',
139 '/MAAS/api/2.0/version/':
140 json.dumps({'version': '2.5.0+curtin-vmtest'})}
141+ override_storage_config_version = None
142
143 # these get set from base_vm_classes
144 release = None
145@@ -2008,19 +2009,34 @@ class VMBaseClass(TestCase):
146
147 @classmethod
148 def get_class_storage_config(cls):
149+ cfg = yaml.safe_load(cls.load_conf_file())
150+ storage_config = cfg.get('storage', {}).get('config', {})
151+ changed = False
152+
153 if cls.target_arch == 'ppc64el':
154- cfg = yaml.safe_load(cls.load_conf_file())
155- new_sc = inject_prep_partition(cfg)
156+ if len(storage_config) == 0:
157+ logger.debug('No storage config, skipping prep injection')
158+ else:
159+ inject_prep_partition(storage_config)
160+ changed = True
161+
162+ if cls.override_storage_config_version is not None:
163+ if storage_config:
164+ cfg['storage']['version'] = cls.override_storage_config_version
165+ changed = True
166+
167+ if changed:
168 # copy testcase YAML to a temp file in order to use updated yaml
169- temp_yaml = tempfile.NamedTemporaryFile(prefix=cls.td.tmpdir + '/',
170- mode='w+t', delete=False)
171- util.write_file(temp_yaml.name, yaml.dump(new_sc,
172- default_flow_style=False, indent=4))
173+ temp_yaml = tempfile.NamedTemporaryFile(
174+ prefix=cls.td.tmpdir + '/',
175+ mode='w+t',
176+ delete=False)
177+ util.write_file(
178+ temp_yaml.name,
179+ yaml.dump(cfg, default_flow_style=False, indent=4))
180 cls.conf_file = temp_yaml.name
181
182- cfg = cls.load_conf_file()
183- sc = yaml.safe_load(cfg).get('storage', {}).get('config', {})
184- return sc
185+ return storage_config
186
187 def get_storage_config(self):
188 cfg = load_config(self.collect_path("root/curtin-install-cfg.yaml"))
189@@ -2573,20 +2589,15 @@ def prep_partition_for_device(device):
190 'size': '8M',
191 'flag': 'prep',
192 'guid': '9e1a2d38-c612-4316-aa26-8b49521e5a8b',
193- 'offset': '1M',
194 'wipe': 'zero',
195 'grub_device': True,
196- 'device': device}
197+ 'device': device,
198+ }
199
200
201-def inject_prep_partition(config):
202+def inject_prep_partition(storage_config):
203 """ Parse a curtin configuration file and inject
204 a prep partition if possible"""
205- storage_config = config.get('storage', {}).get('config', {})
206- if len(storage_config) == 0:
207- logger.debug('No storage config, skipping prep injection')
208- return config
209-
210 logger.info('Injecting PReP Partition')
211 disks = [item for item in storage_config
212 if item['type'] == 'disk']
213@@ -2631,9 +2642,6 @@ def inject_prep_partition(config):
214 if 'flag' in part and part['flag'] in ['boot', 'bios_grub']:
215 del part['flag']
216
217- config['storage']['config'] = storage_config
218- return config
219-
220
221 apply_keep_settings()
222 logger = _initialize_logging()
223diff --git a/tests/vmtests/test_basic.py b/tests/vmtests/test_basic.py
224index 6059bd9..4e0dc8f 100644
225--- a/tests/vmtests/test_basic.py
226+++ b/tests/vmtests/test_basic.py
227@@ -255,10 +255,20 @@ class BionicTestBasic(relbase.bionic, TestBasicAbs):
228 __test__ = True
229
230
231+class BionicTestBasicV2(relbase.bionic, TestBasicAbs):
232+ __test__ = True
233+ override_storage_config_version = 2
234+
235+
236 class FocalTestBasic(relbase.focal, TestBasicAbs):
237 __test__ = True
238
239
240+class FocalTestBasicV2(relbase.focal, TestBasicAbs):
241+ __test__ = True
242+ override_storage_config_version = 2
243+
244+
245 class HirsuteTestBasic(relbase.hirsute, TestBasicAbs):
246 __test__ = True
247
248@@ -267,6 +277,11 @@ class ImpishTestBasic(relbase.impish, TestBasicAbs):
249 __test__ = True
250
251
252+class ImpishTestBasicV2(relbase.impish, TestBasicAbs):
253+ __test__ = True
254+ override_storage_config_version = 2
255+
256+
257 class TestBasicScsiAbs(TestBasicAbs):
258 arch_skip = [
259 'arm64', # arm64 is UEFI only

Subscribers

People subscribed via source and target branches