Skip to content

Commit

Permalink
Merge branch 'SLE-15-SP1' into merge-sle-15-sp1
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Feb 10, 2021
2 parents 55b4747 + 8c88e95 commit 9ef5257
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
7 changes: 7 additions & 0 deletions package/yast2-installation.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Feb 10 08:01:33 UTC 2021 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Do not crash when it is not possible to create a snapshot after
installing or upgrading the system (bsc#1180142).
- 4.2.49

-------------------------------------------------------------------
Mon Dec 7 09:27:38 UTC 2020 - Ladislav Slezák <lslezak@suse.cz>

Expand Down
10 changes: 5 additions & 5 deletions package/yast2-installation.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-installation
Version: 4.2.48
Version: 4.2.49
Release: 0
Group: System/YaST
License: GPL-2.0-only
Expand All @@ -35,8 +35,8 @@ BuildRequires: yast2-ruby-bindings >= 4.0.6
BuildRequires: yast2-xml
BuildRequires: rubygem(%{rb_default_ruby_abi}:rspec)
BuildRequires: rubygem(%{rb_default_ruby_abi}:yast-rake)
# Yast::OSRelease.ReleaseVersionHumanReadable
BuildRequires: yast2 >= 4.2.56
# Yast2::FsSnapshotStore::IOError
BuildRequires: yast2 >= 4.2.92
# Y2Packager::MediumType
BuildRequires: yast2-packager >= 4.2.27
# using /usr/bin/udevadm
Expand Down Expand Up @@ -74,8 +74,8 @@ Requires: yast2-proxy
# Systemd default target and services. This version supports
# writing settings in the first installation stage.
Requires: yast2-services-manager >= 3.2.1
# Yast::OSRelease.ReleaseVersionHumanReadable
Requires: yast2 >= 4.2.56
# Yast2::FsSnapshotStore::IOError
Requires: yast2 >= 4.2.92
# Y2Network::NtpServer
Requires: yast2-network >= 4.2.55
# for AbortException and handle direct abort
Expand Down
9 changes: 9 additions & 0 deletions src/lib/installation/snapshots_finish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def initialize

Yast.import "Mode"
Yast.import "InstFunctions"
Yast.import "Report"
Yast.include self, "installation/misc.rb"
end

Expand Down Expand Up @@ -52,12 +53,20 @@ def create_post_snapshot
Yast2::FsSnapshot.create_post("after update", pre_number, cleanup: :number, important: true)
Yast2::FsSnapshotStore.clean("update")
true
rescue Yast2::SnapshotCreationFailed, Yast2::FsSnapshotStore::IOError => error
log.error("Error creating a post-update snapshot: #{error}")
Yast::Report.Error(_("Could not create a post-update snapshot."))
false
end

def create_single_snapshot
# as of bsc #1092757 snapshot descriptions are not translated
Yast2::FsSnapshot.create_single("after installation", cleanup: :number, important: true)
true
rescue Yast2::SnapshotCreationFailed => error
log.error("Error creating a post-installation snapshot: #{error}")
Yast::Report.Error(_("Could not create a post-installation snapshot."))
false
end

def snapper_config
Expand Down
34 changes: 32 additions & 2 deletions test/snapshots_finish_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,29 @@
context "when updating" do
before do
allow(Yast::Mode).to receive(:update).and_return(true)
allow(Yast2::FsSnapshotStore).to receive(:load).with("update").and_return(1)
allow(Yast2::FsSnapshotStore).to receive(:clean).with("update")
end

it "creates a snapshot of type 'post' with 'after update' as description and paired with 'pre' snapshot" do
expect(Yast2::FsSnapshotStore).to receive(:load).with("update").and_return(1)
expect(Yast2::FsSnapshotStore).to receive(:clean).with("update")
expect(Yast2::FsSnapshot).to receive(:create_post).with("after update", 1, cleanup: :number, important: true).and_return(true)
expect(subject.write).to eq(true)
end

context "and could not create the snapshot" do
before do
allow(Yast2::FsSnapshot).to receive(:create_post).and_raise(Yast2::SnapshotCreationFailed)
end

it "returns false" do
expect(subject.write).to eq(false)
end

it "reports the problem to the user" do
expect(Yast::Report).to receive(:Error).with(/snapshot/)
subject.write
end
end
end

context "when installing" do
Expand All @@ -117,6 +132,21 @@
expect(Yast2::FsSnapshot).to receive(:create_single).with("after installation", cleanup: :number, important: true).and_return(true)
expect(subject.write).to eq(true)
end

context "and could not create the snapshot" do
before do
allow(Yast2::FsSnapshot).to receive(:create_single).and_raise(Yast2::SnapshotCreationFailed)
end

it "returns false" do
expect(subject.write).to eq(false)
end

it "reports the problem to the user" do
expect(Yast::Report).to receive(:Error).with(/snapshot/)
subject.write
end
end
end
end

Expand Down

0 comments on commit 9ef5257

Please sign in to comment.