Skip to content

Commit

Permalink
Merge pull request #1368 from yast/merged_sle15sp6
Browse files Browse the repository at this point in the history
Merged sle15sp6
  • Loading branch information
mchf authored Feb 16, 2024
2 parents b700ab0 + edd1d87 commit 7157f8f
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 6 deletions.
8 changes: 8 additions & 0 deletions package/yast2-storage-ng.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Wed Feb 14 09:11:06 UTC 2024 - Michal Filka <[email protected]>

- jsc#PED-6407
- new env variable YAST_REUSE_LVM for reusing LVM in new
installation. It can be used as linuxrc boot param.
- 5.0.6

-------------------------------------------------------------------
Mon Feb 12 15:18:51 UTC 2024 - Stefan Hundhammer <[email protected]>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-storage-ng.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-storage-ng
Version: 5.0.5
Version: 5.0.6
Release: 0
Summary: YaST2 - Storage Configuration
License: GPL-2.0-only OR GPL-3.0-only
Expand Down
2 changes: 0 additions & 2 deletions src/lib/y2storage/proposal/lvm_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ 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
Expand Down
10 changes: 10 additions & 0 deletions src/lib/y2storage/proposal_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
require "y2storage/encryption_method"
require "y2storage/equal_by_instance_variables"
require "y2storage/proposal_space_settings"
require "y2storage/storage_env"

module Y2Storage
# Class to manage settings used by the proposal (typically read from control.xml)
Expand Down Expand Up @@ -245,6 +246,7 @@ def self.new_for_current_product
def for_current_product
apply_defaults
load_features
apply_user_enforced
end

# Produces a deep copy of settings
Expand Down Expand Up @@ -411,6 +413,14 @@ def apply_defaults
end
end

# Some values can be explicitly enforced by user
# This setting should have precendence over everything else
def apply_user_enforced
value = StorageEnv.instance.requested_lvm_reuse

send(:lvm_vg_reuse=, StorageEnv.instance.requested_lvm_reuse) if !value.nil?
end

# Overrides the settings with values read from the YaST product features
# (i.e. values in /control.xml).
#
Expand Down
27 changes: 24 additions & 3 deletions src/lib/y2storage/storage_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ class StorageEnv

ENV_LIBSTORAGE_IGNORE_PROBE_ERRORS = "LIBSTORAGE_IGNORE_PROBE_ERRORS".freeze

ENV_REUSE_LVM = "YAST_REUSE_LVM".freeze

private_constant :ENV_MULTIPATH, :ENV_BIOS_RAID, :ENV_ACTIVATE_LUKS, :ENV_LUKS2_AVAILABLE
private_constant :ENV_LIBSTORAGE_IGNORE_PROBE_ERRORS
private_constant :ENV_REUSE_LVM

def initialize
reset_cache
Expand Down Expand Up @@ -89,6 +92,19 @@ def luks2_available?
active?(ENV_LUKS2_AVAILABLE, default: false)
end

# Whether YaST should reuse existing LVM
#
# see jsc#PED-6407 or jsc#IBM-1315
#
# @return [Boolean, nil] boolean as explicitly set by user, nil if user set nothing
def requested_lvm_reuse
value = read(ENV_REUSE_LVM)

return nil if !value

env_str_to_bool(value)
end

# Whether errors during libstorage probing should be ignored.
#
# See bsc#1177332:
Expand All @@ -106,6 +122,13 @@ def ignore_probe_errors?

private

# Takes a string and translates it to bool in a similar way how linuxrc does
def env_str_to_bool(value)
# Similar to what linuxrc does, also consider the flag activated if the
# variable is used with no value or with "1"
value.casecmp?("on") || value.empty? || value == "1"
end

# Whether the env variable is active
#
# @param variable [String]
Expand All @@ -116,9 +139,7 @@ def active?(variable, default: false)

value = read(variable)
result = if value
# Similar to what linuxrc does, also consider the flag activated if the
# variable is used with no value or with "1"
value.casecmp?("on") || value.empty? || value == "1"
env_str_to_bool(value)
else
default
end
Expand Down
32 changes: 32 additions & 0 deletions test/y2storage/storage_env_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,36 @@
end
end
end

describe "#requested_lvm_reuse" do
context "YAST_REUSE_LVM is set to '1'" do
let(:env_vars) do
{ "YAST_REUSE_LVM" => "1" }
end

it "returns true" do
expect(Y2Storage::StorageEnv.instance.requested_lvm_reuse).to be true
end
end

context "YAST_REUSE_LVM is set to '0'" do
let(:env_vars) do
{ "YAST_REUSE_LVM" => "0" }
end

it "returns false" do
expect(Y2Storage::StorageEnv.instance.requested_lvm_reuse).to be false
end
end

context "YAST_REUSE_LVM not set" do
let(:env_vars) do
{}
end

it "returns nil" do
expect(Y2Storage::StorageEnv.instance.requested_lvm_reuse).to be nil
end
end
end
end

0 comments on commit 7157f8f

Please sign in to comment.