Merge ~mwhudson/curtin:vmtest-preserve-raid into curtin:master

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Ryan Harper
Approved revision: 832b759f67c5f69ec107c0b9da5ad9c9eb5dfc84
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~mwhudson/curtin:vmtest-preserve-raid
Merge into: curtin:master
Prerequisite: ~mwhudson/curtin:vmtest-preserve-partition
Diff against target: 185 lines (+149/-2)
4 files modified
curtin/block/mdadm.py (+1/-1)
examples/tests/preserve-raid.yaml (+108/-0)
tests/unittests/test_block_mdadm.py (+1/-1)
tests/vmtests/test_preserve_raid.py (+39/-0)
Reviewer Review Type Date Requested Status
Ryan Harper (community) Approve
Server Team CI bot continuous-integration Approve
Dan Watkins (community) Approve
Review via email: mp+367950@code.launchpad.net

Commit message

mdadm: fix install to existing raid

Just change the export=False to export=True in the call to mdadm_examine
in md_check_array_membership.

LP: #1830157

Description of the change

Turns out the first problem I bumped into installing to existing raid was the only one (for this scenario anyway). Still, the test seems worth the hair-pulling involved in writing it!

To post a comment you must log in.
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: Approve (continuous-integration)
Revision history for this message
Dan Watkins (oddbloke) wrote :

This looks good to me; I don't (think I) have access to a system with a RAID array to double-check the output of commands, so I'm going to leave this to someone with more nous to merge.

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

Nice! Inline comment on extra newlines. I'll kick off a vmtest run on this

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

That passed. Let's fix up the extra newlines in the config yaml and add classes for Cosmic, Disco and Eoan; subiquity can run these re-use scenarios on any of these releases.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/block/mdadm.py b/curtin/block/mdadm.py
2index d8373e3..b7c4d06 100644
3--- a/curtin/block/mdadm.py
4+++ b/curtin/block/mdadm.py
5@@ -819,7 +819,7 @@ def md_check_array_membership(md_devname, devices):
6 # validate that all devices are members of the correct array
7 md_uuid = md_get_uuid(md_devname)
8 for device in devices:
9- dev_examine = mdadm_examine(device, export=False)
10+ dev_examine = mdadm_examine(device, export=True)
11 if 'MD_UUID' not in dev_examine:
12 raise ValueError('Device is not part of an array: ' + device)
13 dev_uuid = dev_examine['MD_UUID']
14diff --git a/examples/tests/preserve-raid.yaml b/examples/tests/preserve-raid.yaml
15new file mode 100644
16index 0000000..3a6cc18
17--- /dev/null
18+++ b/examples/tests/preserve-raid.yaml
19@@ -0,0 +1,108 @@
20+showtrace: true
21+
22+bucket:
23+ - &setup |
24+ parted /dev/disk/by-id/virtio-disk-b --script -- \
25+ mklabel gpt \
26+ mkpart primary 1GiB 9GiB
27+ parted /dev/disk/by-id/virtio-disk-c --script -- \
28+ mklabel gpt \
29+ mkpart primary 1GiB 9GiB
30+ udevadm settle
31+ mdadm --create --metadata 1.2 --level 1 -n 2 /dev/md1 --assume-clean \
32+ /dev/disk/by-id/virtio-disk-b-part1 /dev/disk/by-id/virtio-disk-c-part1
33+ udevadm settle
34+ mkfs.ext4 /dev/md1
35+ mount /dev/md1 /mnt
36+ touch /mnt/existing
37+ umount /mnt
38+ mdadm --stop /dev/md1
39+ udevadm settle
40+
41+# Create a RAID now to test curtin's reuse of existing RAIDs.
42+early_commands:
43+ 00-setup-raid: [sh, -exuc, *setup]
44+
45+storage:
46+ config:
47+ - type: disk
48+ id: id_disk0
49+ serial: disk-a
50+ ptable: gpt
51+ wipe: superblock
52+ - type: disk
53+ id: id_disk1
54+ serial: disk-b
55+ ptable: gpt
56+ preserve: true
57+ - type: disk
58+ id: id_disk2
59+ serial: disk-c
60+ ptable: gpt
61+ preserve: true
62+ - type: partition
63+ id: id_disk0_part1
64+ device: id_disk0
65+ flag: boot
66+ number: 1
67+ size: 512M
68+ - type: partition
69+ id: id_disk0_part2
70+ device: id_disk0
71+ number: 2
72+ size: 3G
73+ - type: partition
74+ id: id_disk0_part3
75+ device: id_disk0
76+ number: 3
77+ size: 3G
78+ - type: partition
79+ id: id_disk1_part1
80+ device: id_disk1
81+ flag: boot
82+ number: 1
83+ size: 8G
84+ preserve: true
85+ - type: partition
86+ id: id_disk2_part1
87+ device: id_disk2
88+ flag: boot
89+ number: 1
90+ size: 8G
91+ preserve: true
92+ - type: raid
93+ id: raid-md1
94+ name: md1
95+ raidlevel: raid1
96+ devices:
97+ - id_disk1_part1
98+ - id_disk2_part1
99+ spare_devices: []
100+ metadata: 1.2
101+ preserve: true
102+ - type: format
103+ id: id_efi_format
104+ volume: id_disk0_part1
105+ fstype: fat32
106+ - type: format
107+ id: id_root_format
108+ volume: id_disk0_part2
109+ fstype: ext4
110+ - type: format
111+ id: id_raid-md1_format
112+ volume: raid-md1
113+ fstype: ext4
114+ preserve: true
115+ - type: mount
116+ device: id_root_format
117+ id: id_root_mount
118+ path: /
119+ - type: mount
120+ id: id_efi_mount
121+ device: id_efi_format
122+ path: /boot/efi
123+ - type: mount
124+ id: id_raid-md1_mount
125+ device: id_raid-md1_format
126+ path: /srv
127+ version: 1
128diff --git a/tests/unittests/test_block_mdadm.py b/tests/unittests/test_block_mdadm.py
129index f9164b4..e778871 100644
130--- a/tests/unittests/test_block_mdadm.py
131+++ b/tests/unittests/test_block_mdadm.py
132@@ -994,7 +994,7 @@ class TestBlockMdadmMdHelpers(CiTestCase):
133 mock_examine.side_effect = [md_dict] * len(devices)
134 expected_calls = []
135 for dev in devices:
136- expected_calls.append(call(dev, export=False))
137+ expected_calls.append(call(dev, export=True))
138
139 rv = mdadm.md_check_array_membership(mdname, devices)
140
141diff --git a/tests/vmtests/test_preserve_raid.py b/tests/vmtests/test_preserve_raid.py
142new file mode 100644
143index 0000000..cf2b808
144--- /dev/null
145+++ b/tests/vmtests/test_preserve_raid.py
146@@ -0,0 +1,39 @@
147+# This file is part of curtin. See LICENSE file for copyright and license info.
148+
149+from . import VMBaseClass
150+from .releases import base_vm_classes as relbase
151+
152+import textwrap
153+
154+
155+class TestPreserveRAID(VMBaseClass):
156+ """ Test that curtin can reuse a RAID. """
157+ conf_file = "examples/tests/preserve-raid.yaml"
158+ extra_disks = ['10G', '10G', '10G']
159+ uefi = True
160+ extra_collect_scripts = [textwrap.dedent("""
161+ cd OUTPUT_COLLECT_D
162+ ls /srv > ls-srv
163+ exit 0
164+ """)]
165+
166+ def test_existing_exists(self):
167+ self.assertIn('existing', self.load_collect_file('ls-srv'))
168+
169+
170+class BionicTestPreserveRAID(relbase.bionic, TestPreserveRAID):
171+ __test__ = True
172+
173+
174+class CosmicTestPreserveRAID(relbase.cosmic, TestPreserveRAID):
175+ __test__ = True
176+
177+
178+class DiscoTestPreserveRAID(relbase.disco, TestPreserveRAID):
179+ __test__ = True
180+
181+
182+class EoanTestPreserveRAID(relbase.eoan, TestPreserveRAID):
183+ __test__ = True
184+
185+# vi: ts=4 expandtab syntax=python

Subscribers

People subscribed via source and target branches