Skip to content

Commit

Permalink
Fix recalculation when storage has changed
Browse files Browse the repository at this point in the history
  • Loading branch information
ancorgs committed Jan 26, 2021
1 parent 74ff590 commit 23816b5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/lib/bootloader/proposal_client.rb
Expand Up @@ -131,13 +131,15 @@ def description

# make proposal without handling of exceptions
def make_proposal_raising(attrs)
force_reset = attrs["force_reset"]
storage_read = Yast::BootStorage.storage_read?
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 23816b5

Please sign in to comment.