Skip to content

Commit

Permalink
Improved saving y2logs during installation (bsc#1118643) (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Dec 6, 2018
1 parent 0f61f32 commit 9052115
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
8 changes: 8 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Thu Dec 6 12:59:03 UTC 2018 - lslezak@suse.cz

- Improved saving y2logs during installation to use the /mnt/tmp
space instead of the RAM disk to avoid possible crash (out of
memory) (bsc#1118643)
- 4.1.31

-------------------------------------------------------------------
Sat Nov 24 19:40:43 UTC 2018 - Stasiek Michalski <hellcp@mailbox.org>

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

Name: yast2-installation
Version: 4.1.30
Version: 4.1.31
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
8 changes: 7 additions & 1 deletion src/lib/installation/clients/save_y2logs.rb
Expand Up @@ -17,8 +17,14 @@ def main
Yast::Directory.logdir
)

# use the target /tmp when available to save memory
target_tmp = File.join(Yast::Installation.destdir, "tmp")
tmpdir = File.exist?(target_tmp) ? target_tmp : "/tmp"

WFM.Execute(Yast::Path.new(".local.bash"),
"/usr/sbin/save_y2logs '#{target_path}/yast-installation-logs.tar.xz'")
# set TMPDIR for `mktemp -d` so it uses the target disk, not inst-sys RAM disk
# https://github.com/yast/yast-yast2/blob/482eecb6064e2a904864fdab17e8c4bed41065ff/scripts/save_y2logs#L72
"TMPDIR=#{tmpdir} /usr/sbin/save_y2logs '#{target_path}/yast-installation-logs.tar.xz'")
end
end
end
Expand Down
23 changes: 20 additions & 3 deletions test/lib/clients/save_y2logs_test.rb
Expand Up @@ -11,23 +11,40 @@
describe "#main" do
let(:bash_path) { Yast::Path.new(".local.bash") }

before do
allow(Yast::Installation).to receive(:destdir).and_return("/mnt")
allow(File).to receive(:exist?).and_return(false)
end

context "globals/save_y2logs in control.xml is false" do
it "does not save y2logs" do
expect(Yast::ProductFeatures).to receive(:GetBooleanFeature).with("globals", "save_y2logs").and_return(false)
expect(Yast::WFM).not_to receive(:Execute).with(
bash_path,
"/usr/sbin/save_y2logs '/var/log/YaST2/yast-installation-logs.tar.xz'"
/save_y2logs/
)
client.main
end
end

context "globals/save_y2logs in control.xml is true" do
it "saves y2logs" do
before do
expect(Yast::ProductFeatures).to receive(:GetBooleanFeature).with("globals", "save_y2logs").and_return(true)
end

it "saves y2logs" do
expect(Yast::WFM).to receive(:Execute).with(
bash_path,
"TMPDIR=/tmp /usr/sbin/save_y2logs '/mnt/var/log/YaST2/yast-installation-logs.tar.xz'"
)
client.main
end

it "uses the target /tmp when it exists" do
expect(File).to receive(:exist?).with("/mnt/tmp").and_return(true)
expect(Yast::WFM).to receive(:Execute).with(
bash_path,
"/usr/sbin/save_y2logs '/var/log/YaST2/yast-installation-logs.tar.xz'"
"TMPDIR=/mnt/tmp /usr/sbin/save_y2logs '/mnt/var/log/YaST2/yast-installation-logs.tar.xz'"
)
client.main
end
Expand Down

0 comments on commit 9052115

Please sign in to comment.