Skip to content

Commit

Permalink
Merge pull request #630 from ancorgs/reset_storage
Browse files Browse the repository at this point in the history
Fix recalculation when storage has changed (bsc#1180218, bsc#1180976)
  • Loading branch information
ancorgs committed Jan 27, 2021
2 parents 74ff590 + ea33e9e commit 80fc7bf
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
7 changes: 7 additions & 0 deletions package/yast2-bootloader.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Jan 26 16:54:23 UTC 2021 - Ancor Gonzalez Sosa <ancor@suse.com>

- Ensure the proposal is re-calculated when the partitioning plan
has changed (bsc#1180218 and bsc#1180976)
- 4.3.19

-------------------------------------------------------------------
Thu Jan 21 14:53:55 UTC 2021 - José Iván López González <jlopez@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-bootloader.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-bootloader
Version: 4.3.18
Version: 4.3.19
Release: 0
Summary: YaST2 - Bootloader Configuration
License: GPL-2.0-or-later
Expand Down
11 changes: 8 additions & 3 deletions src/lib/bootloader/proposal_client.rb
Expand Up @@ -131,13 +131,18 @@ def description

# make proposal without handling of exceptions
def make_proposal_raising(attrs)
force_reset = attrs["force_reset"]
storage_read = Yast::BootStorage.storage_read?
# This must be checked at the beginning because the call to BootStorage.boot_filesystem
# below can trigger a re-read and change the result of BootStorage.storage_changed?
# See bsc#1180218 and bsc#1180976.
storage_changed = Yast::BootStorage.storage_changed?

if Yast::BootStorage.boot_filesystem.is?(:nfs)
::Bootloader::BootloaderFactory.current_name = "none"
return construct_proposal_map
end
force_reset = attrs["force_reset"]
storage_read = Yast::BootStorage.storage_read?
storage_changed = Yast::BootStorage.storage_changed?

log.info "Storage changed: #{storage_changed} force_reset #{force_reset}."
log.info "Storage read previously #{storage_read.inspect}"
# clear storage-ng devices cache otherwise it crashes (bsc#1071931)
Expand Down
24 changes: 20 additions & 4 deletions test/bootloader_proposal_client_test.rb
Expand Up @@ -196,11 +196,27 @@
subject.make_proposal({})
end

it "always resets if storage changed" do
it "does not reset the configuration if the user already changed it" do
# Run a first proposal
subject.make_proposal({})
# The user edits (or simply visualizes) the configuration
Yast::Bootloader.proposed_cfg_changed = true

expect(Yast::Bootloader).to_not receive(:Reset)
subject.make_proposal("force_reset" => false)
end

# Regression test for bsc#1180218 and bsc#1180976
it "resets the configuration if storage changed" do
# Run a first proposal
subject.make_proposal({})
# The user edits (or simply visualizes) the configuration
Yast::Bootloader.proposed_cfg_changed = true

Y2Storage::StorageManager.instance.increase_staging_revision
expect(Yast::Bootloader).to receive(:Reset)
allow(Yast::BootStorage).to receive(:storage_changed?).and_return(true)

subject.make_proposal("force_reset" => true)
subject.make_proposal("force_reset" => false)
end

it "resets configuration if not automode and force_reset passed" do
Expand All @@ -209,7 +225,7 @@
subject.make_proposal("force_reset" => true)
end

it "do not resets configuration in automode and even if force_reset passed" do
it "does not reset configuration in automode and even if force_reset passed" do
allow(Yast::Mode).to receive(:autoinst).and_return(true)
expect(Yast::Bootloader).to_not receive(:Reset)

Expand Down

0 comments on commit 80fc7bf

Please sign in to comment.