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
1diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py
2index e3c4ce1..65e779f 100644
3--- a/curtin/commands/block_meta.py
4+++ b/curtin/commands/block_meta.py
5@@ -1692,8 +1692,8 @@ def zfs_handler(info, storage_config):
6
7
8 def get_device_paths_from_storage_config(storage_config):
9- """Returns a list of device paths in a storage config filtering out
10- preserved or devices which do not have wipe configuration.
11+ """Returns a list of device paths in a storage config which have wipe
12+ config enabled.
13
14 :param: storage_config: Ordered dict of storage configation
15 """
16@@ -1701,8 +1701,6 @@ def get_device_paths_from_storage_config(storage_config):
17 for (k, v) in storage_config.items():
18 if v.get('type') in ['disk', 'partition']:
19 if config.value_as_boolean(v.get('wipe')):
20- if config.value_as_boolean(v.get('preserve')):
21- continue
22 try:
23 dpaths.append(
24 get_path_to_storage_volume(k, storage_config))
25diff --git a/examples/tests/preserve-partition-wipe-vg-simple.yaml b/examples/tests/preserve-partition-wipe-vg-simple.yaml
26new file mode 100644
27index 0000000..662f34f
28--- /dev/null
29+++ b/examples/tests/preserve-partition-wipe-vg-simple.yaml
30@@ -0,0 +1,62 @@
31+showtrace: true
32+
33+bucket:
34+ - &setup |
35+ parted /dev/disk/by-id/virtio-disk-a --script -- \
36+ mklabel gpt \
37+ mkpart primary ext4 2MiB 4MiB \
38+ set 1 bios_grub on \
39+ mkpart primary ext4 4GiB 7GiB
40+ udevadm settle
41+ ls -al /dev/disk/by-id
42+ vgcreate --force --zero=y --yes root_vg /dev/disk/by-id/virtio-disk-a-part2
43+ pvscan --cache
44+ vgscan --mknodes --cache
45+ vgs
46+ lvcreate root_vg --name lv1_root --zero=y --wipesignatures=y \
47+ --size 2G
48+ udevadm settle
49+ lvs
50+ ls -al /dev/disk/by-id
51+
52+# Partition the disk now to test curtin's reuse of partitions.
53+early_commands:
54+ 00-setup-disk: [sh, -exuc, *setup]
55+
56+storage:
57+ config:
58+ - ptable: gpt
59+ serial: disk-a
60+ preserve: true
61+ name: disk-a
62+ grub_device: true
63+ type: disk
64+ id: disk-sda
65+ - device: disk-sda
66+ size: 2097152
67+ flag: bios_grub
68+ preserve: true
69+ number: 1
70+ type: partition
71+ id: disk-sda-part-1
72+ - device: disk-sda
73+ size: 3G
74+ flag: linux
75+ preserve: true
76+ number: 2
77+ wipe: zero
78+ type: partition
79+ id: disk-sda-part-2
80+ - fstype: ext4
81+ volume: disk-sda-part-2
82+ preserve: false
83+ type: format
84+ id: format-0
85+ - device: format-0
86+ path: /
87+ type: mount
88+ id: mount-0
89+ version: 1
90+
91+verbosity: 3
92+
93diff --git a/tests/vmtests/test_preserve_partition_wipe_vg.py b/tests/vmtests/test_preserve_partition_wipe_vg.py
94index b779ad1..96346ff 100644
95--- a/tests/vmtests/test_preserve_partition_wipe_vg.py
96+++ b/tests/vmtests/test_preserve_partition_wipe_vg.py
97@@ -33,4 +33,27 @@ class FocalTestPreserveWipeLvm(relbase.focal, TestPreserveWipeLvm):
98 __test__ = True
99
100
101+class TestPreserveWipeLvmSimple(VMBaseClass):
102+ conf_file = "examples/tests/preserve-partition-wipe-vg-simple.yaml"
103+ uefi = False
104+ extra_collect_scripts = [textwrap.dedent("""
105+ cd OUTPUT_COLLECT_D
106+ ls /opt > ls-opt
107+ exit 0
108+ """)]
109+
110+
111+class BionicTestPreserveWipeLvmSimple(relbase.bionic,
112+ TestPreserveWipeLvmSimple):
113+ __test__ = True
114+
115+
116+class EoanTestPreserveWipeLvmSimple(relbase.eoan, TestPreserveWipeLvmSimple):
117+ __test__ = True
118+
119+
120+class FocalTestPreserveWipeLvmSimple(relbase.focal, TestPreserveWipeLvmSimple):
121+ __test__ = True
122+
123+
124 # vi: ts=4 expandtab syntax=python

Subscribers

People subscribed via source and target branches