Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] New setting to not reuse LVM volume groups #1316

Merged
merged 2 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package/yast2-storage-ng.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Nov 29 15:07:25 UTC 2022 - Ancor Gonzalez Sosa <[email protected]>

- Proposal: new setting to prevent reusing LVM volume groups
(related to gh#yast/d-installer#264).

-------------------------------------------------------------------
Mon Nov 21 11:33:52 UTC 2022 - Ancor Gonzalez Sosa <[email protected]>

Expand Down
5 changes: 5 additions & 0 deletions src/lib/y2storage/proposal/lvm_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ def new_volume_group
#
# @return [Boolean]
def try_to_reuse?
# Setting introduced to completely avoid LVM reusing in D-Installer.
# It's a new playground, so no need to carry YaST behaviors that have
# proven to be confusing.
return false if settings.lvm_vg_reuse == false

# We introduced this when we still didn't have a mechanism to activate
# existing LUKS. Now such mechanism exists but this check has never been
# removed. Nobody complained so far.
Expand Down
6 changes: 6 additions & 0 deletions src/lib/y2storage/proposal_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ def candidate_devices=(devices)
# specify the predefined size of the LVM volume group.
attr_accessor :lvm_vg_size

# @return [Boolean] whether a pre-existing LVM volume group should be reused if
# the conditions to do so are met. That is the historical YaST behavior, which
# can be inhibited by setting this to false.
attr_accessor :lvm_vg_reuse

# @return [Array<VolumeSpecification>] list of volumes specifications used during
# the proposal
attr_accessor :volumes
Expand Down Expand Up @@ -398,6 +403,7 @@ def root_volume
linux_delete_mode: :ondemand,
lvm: false,
lvm_vg_strategy: :use_available,
lvm_vg_reuse: true,
encryption_method: EncryptionMethod::LUKS1,
multidisk_first: false,
other_delete_mode: :ondemand,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
- disk:
name: "/dev/sda"
size: 800 GiB
partition_table: msdos
partitions:

- partition:
size: 730 GiB
name: /dev/sda1
id: ntfs
file_system: ntfs
label: windows

- partition:
size: unlimited
name: /dev/sda2
id: lvm

- lvm_vg:
vg_name: system
lvm_lvs:

- lvm_lv:
lv_name: root
size: 40 GiB
file_system: btrfs
mount_point: "/"

- lvm_lv:
lv_name: home
size: 28668 MiB
file_system: xfs
mount_point: "/home"

- lvm_lv:
lv_name: swap
size: 2 GiB
file_system: swap
mount_point: swap

lvm_pvs:
- lvm_pv:
blk_device: /dev/sda2
45 changes: 45 additions & 0 deletions test/data/devicegraphs/output/windows-linux-lvm-noreuse-lvm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
- disk:
name: "/dev/sda"
size: 800 GiB
partition_table: msdos
partitions:

- partition:
size: 730 GiB
name: /dev/sda1
id: ntfs
file_system: ntfs
label: windows

- partition:
size: 50 GiB
name: /dev/sda2
id: lvm

- partition:
size: unlimited
name: /dev/sda3
id: 0xb
file_system: vfat
label: recovery

- lvm_vg:
vg_name: system
lvm_lvs:

- lvm_lv:
lv_name: root
size: 40 GiB
file_system: btrfs
mount_point: "/"

- lvm_lv:
lv_name: swap
size: 2 GiB
file_system: swap
mount_point: swap

lvm_pvs:
- lvm_pv:
blk_device: /dev/sda2
16 changes: 16 additions & 0 deletions test/y2storage/proposal/lvm_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
expect(helper.reusable_volume_groups(fake_devicegraph)).to eq []
end
end

context "and ProposalSettings#lvm_vg_reuse is set to false" do
before { settings.lvm_vg_reuse = false }

it "returns an empty array" do
expect(helper.reusable_volume_groups(fake_devicegraph)).to eq []
end
end
end

context "if some volume groups are big enough" do
Expand Down Expand Up @@ -102,6 +110,14 @@
expect(helper.reusable_volume_groups(fake_devicegraph)).to eq []
end
end

context "and ProposalSettings#lvm_vg_reuse is set to false" do
before { settings.lvm_vg_reuse = false }

it "returns an empty array" do
expect(helper.reusable_volume_groups(fake_devicegraph)).to eq []
end
end
end
end

Expand Down
7 changes: 7 additions & 0 deletions test/y2storage/proposal_scenarios_x86_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@
let(:scenario) { "windows-linux-lvm-pc" }
include_examples "LVM-based proposed layouts"
include_examples "partition-based proposed layouts"

context "if the proposal is configured to not reuse volume groups" do
before { settings.lvm_vg_reuse = false }

let(:expected_scenario) { "windows-linux-lvm-noreuse" }
include_examples "LVM-based proposed layouts"
end
end

context "in a windows-only PC with GPT partition table" do
Expand Down