Merge ~raharper/curtin:fix/reuse-vg-partition-simple into curtin:master

Proposed by Ryan Harper
Status: Merged
Approved by: Ryan Harper
Approved revision: 074f345594ed753a70100d856cb8617affc69e55
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~raharper/curtin:fix/reuse-vg-partition-simple
Merge into: curtin:master
Diff against target: 124 lines (+87/-4)
3 files modified
curtin/commands/block_meta.py (+2/-4)
examples/tests/preserve-partition-wipe-vg-simple.yaml (+62/-0)
tests/vmtests/test_preserve_partition_wipe_vg.py (+23/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Paride Legovini Approve
Michael Hudson-Doyle Approve
Chad Smith Pending
Review via email: mp+382505@code.launchpad.net

Commit message

block-meta: don't filter preserve=true devices, select by wipe

Now that wiping and preserving are independent values we consider
any disk or partition with a wipe setting for clearing holders.
An existing scenario where this matters is reusing a partition
which was previously part of a volume-group.

- Add a simplified vmtest scenario for reusing partition that
  was previously part of a volume-group

LP: #1837214

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
Chad Smith (chad.smith) :
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Ah ha!

review: Approve
Revision history for this message
Paride Legovini (paride) :
review: Approve
074f345... by Ryan Harper

Adjust docstring, remove filter comment.

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)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py
index e3c4ce1..65e779f 100644
--- a/curtin/commands/block_meta.py
+++ b/curtin/commands/block_meta.py
@@ -1692,8 +1692,8 @@ def zfs_handler(info, storage_config):
16921692
16931693
1694def get_device_paths_from_storage_config(storage_config):1694def get_device_paths_from_storage_config(storage_config):
1695 """Returns a list of device paths in a storage config filtering out1695 """Returns a list of device paths in a storage config which have wipe
1696 preserved or devices which do not have wipe configuration.1696 config enabled.
16971697
1698 :param: storage_config: Ordered dict of storage configation1698 :param: storage_config: Ordered dict of storage configation
1699 """1699 """
@@ -1701,8 +1701,6 @@ def get_device_paths_from_storage_config(storage_config):
1701 for (k, v) in storage_config.items():1701 for (k, v) in storage_config.items():
1702 if v.get('type') in ['disk', 'partition']:1702 if v.get('type') in ['disk', 'partition']:
1703 if config.value_as_boolean(v.get('wipe')):1703 if config.value_as_boolean(v.get('wipe')):
1704 if config.value_as_boolean(v.get('preserve')):
1705 continue
1706 try:1704 try:
1707 dpaths.append(1705 dpaths.append(
1708 get_path_to_storage_volume(k, storage_config))1706 get_path_to_storage_volume(k, storage_config))
diff --git a/examples/tests/preserve-partition-wipe-vg-simple.yaml b/examples/tests/preserve-partition-wipe-vg-simple.yaml
1709new file mode 1006441707new file mode 100644
index 0000000..662f34f
--- /dev/null
+++ b/examples/tests/preserve-partition-wipe-vg-simple.yaml
@@ -0,0 +1,62 @@
1showtrace: true
2
3bucket:
4 - &setup |
5 parted /dev/disk/by-id/virtio-disk-a --script -- \
6 mklabel gpt \
7 mkpart primary ext4 2MiB 4MiB \
8 set 1 bios_grub on \
9 mkpart primary ext4 4GiB 7GiB
10 udevadm settle
11 ls -al /dev/disk/by-id
12 vgcreate --force --zero=y --yes root_vg /dev/disk/by-id/virtio-disk-a-part2
13 pvscan --cache
14 vgscan --mknodes --cache
15 vgs
16 lvcreate root_vg --name lv1_root --zero=y --wipesignatures=y \
17 --size 2G
18 udevadm settle
19 lvs
20 ls -al /dev/disk/by-id
21
22# Partition the disk now to test curtin's reuse of partitions.
23early_commands:
24 00-setup-disk: [sh, -exuc, *setup]
25
26storage:
27 config:
28 - ptable: gpt
29 serial: disk-a
30 preserve: true
31 name: disk-a
32 grub_device: true
33 type: disk
34 id: disk-sda
35 - device: disk-sda
36 size: 2097152
37 flag: bios_grub
38 preserve: true
39 number: 1
40 type: partition
41 id: disk-sda-part-1
42 - device: disk-sda
43 size: 3G
44 flag: linux
45 preserve: true
46 number: 2
47 wipe: zero
48 type: partition
49 id: disk-sda-part-2
50 - fstype: ext4
51 volume: disk-sda-part-2
52 preserve: false
53 type: format
54 id: format-0
55 - device: format-0
56 path: /
57 type: mount
58 id: mount-0
59 version: 1
60
61verbosity: 3
62
diff --git a/tests/vmtests/test_preserve_partition_wipe_vg.py b/tests/vmtests/test_preserve_partition_wipe_vg.py
index b779ad1..96346ff 100644
--- a/tests/vmtests/test_preserve_partition_wipe_vg.py
+++ b/tests/vmtests/test_preserve_partition_wipe_vg.py
@@ -33,4 +33,27 @@ class FocalTestPreserveWipeLvm(relbase.focal, TestPreserveWipeLvm):
33 __test__ = True33 __test__ = True
3434
3535
36class TestPreserveWipeLvmSimple(VMBaseClass):
37 conf_file = "examples/tests/preserve-partition-wipe-vg-simple.yaml"
38 uefi = False
39 extra_collect_scripts = [textwrap.dedent("""
40 cd OUTPUT_COLLECT_D
41 ls /opt > ls-opt
42 exit 0
43 """)]
44
45
46class BionicTestPreserveWipeLvmSimple(relbase.bionic,
47 TestPreserveWipeLvmSimple):
48 __test__ = True
49
50
51class EoanTestPreserveWipeLvmSimple(relbase.eoan, TestPreserveWipeLvmSimple):
52 __test__ = True
53
54
55class FocalTestPreserveWipeLvmSimple(relbase.focal, TestPreserveWipeLvmSimple):
56 __test__ = True
57
58
36# vi: ts=4 expandtab syntax=python59# vi: ts=4 expandtab syntax=python

Subscribers

People subscribed via source and target branches