Hello community, here is the log from the commit of package yast2-kdump for openSUSE:Factory checked in at 2015-07-05 17:52:41 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-kdump (Old) and /work/SRC/openSUSE:Factory/.yast2-kdump.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-kdump" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-kdump/yast2-kdump.changes 2015-06-03 08:24:32.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-kdump.new/yast2-kdump.changes 2015-07-05 17:52:42.000000000 +0200 @@ -1,0 +2,14 @@ +Wed Jul 1 15:26:31 CEST 2015 - dvaleev@suse.com + +- Require kdump on aarch64 but recommend on ppc32 this time. + kdump made available on aarch64. This time it is ppc32's turn + +- 3.1.24 +------------------------------------------------------------------- +Wed Jun 17 10:26:31 CEST 2015 - locilka@suse.com + +- Warn user in installation proposal if space available on disk + is smaller than RAM size + 4 GB (FATE#317488) +- 3.1.23 + +------------------------------------------------------------------- Old: ---- yast2-kdump-3.1.22.tar.bz2 New: ---- yast2-kdump-3.1.24.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-kdump.spec ++++++ --- /var/tmp/diff_new_pack.BqUBRA/_old 2015-07-05 17:52:43.000000000 +0200 +++ /var/tmp/diff_new_pack.BqUBRA/_new 2015-07-05 17:52:43.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-kdump -Version: 3.1.22 +Version: 3.1.24 Release: 0 Summary: Configuration of kdump License: GPL-2.0 @@ -40,9 +40,11 @@ Requires: yast2-bootloader >= 3.1.35 Requires: yast2-ruby-bindings >= 1.0.0 Requires: yast2-storage +# SpaceCalculation.GetPartitionInfo +Requires: yast2-packager Recommends: makedumpfile BuildRoot: %{_tmppath}/%{name}-%{version}-build -%ifarch aarch64 +%ifarch ppc Recommends: kdump %else Requires: kdump ++++++ yast2-kdump-3.1.22.tar.bz2 -> yast2-kdump-3.1.24.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-kdump-3.1.22/package/yast2-kdump.changes new/yast2-kdump-3.1.24/package/yast2-kdump.changes --- old/yast2-kdump-3.1.22/package/yast2-kdump.changes 2015-06-01 16:39:08.000000000 +0200 +++ new/yast2-kdump-3.1.24/package/yast2-kdump.changes 2015-07-01 16:04:39.000000000 +0200 @@ -1,4 +1,18 @@ ------------------------------------------------------------------- +Wed Jul 1 15:26:31 CEST 2015 - dvaleev@suse.com + +- Require kdump on aarch64 but recommend on ppc32 this time. + kdump made available on aarch64. This time it is ppc32's turn + +- 3.1.24 +------------------------------------------------------------------- +Wed Jun 17 10:26:31 CEST 2015 - locilka@suse.com + +- Warn user in installation proposal if space available on disk + is smaller than RAM size + 4 GB (FATE#317488) +- 3.1.23 + +------------------------------------------------------------------- Mon May 25 21:31:15 UTC 2015 - ptesarik@suse.cz - Add 'sftp' dump target, which is distinct from 'ssh' in kdump diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-kdump-3.1.22/package/yast2-kdump.spec new/yast2-kdump-3.1.24/package/yast2-kdump.spec --- old/yast2-kdump-3.1.22/package/yast2-kdump.spec 2015-06-01 16:39:08.000000000 +0200 +++ new/yast2-kdump-3.1.24/package/yast2-kdump.spec 2015-07-01 16:04:39.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-kdump -Version: 3.1.22 +Version: 3.1.24 Release: 0 Summary: Configuration of kdump License: GPL-2.0 @@ -40,9 +40,11 @@ Requires: yast2-bootloader >= 3.1.35 Requires: yast2-ruby-bindings >= 1.0.0 Requires: yast2-storage +# SpaceCalculation.GetPartitionInfo +Requires: yast2-packager Recommends: makedumpfile BuildRoot: %{_tmppath}/%{name}-%{version}-build -%ifarch aarch64 +%ifarch ppc Recommends: kdump %else Requires: kdump diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-kdump-3.1.22/src/clients/kdump_proposal.rb new/yast2-kdump-3.1.24/src/clients/kdump_proposal.rb --- old/yast2-kdump-3.1.22/src/clients/kdump_proposal.rb 2015-06-01 16:39:08.000000000 +0200 +++ new/yast2-kdump-3.1.24/src/clients/kdump_proposal.rb 2015-07-01 16:04:39.000000000 +0200 @@ -41,7 +41,21 @@ if @func == "MakeProposal" Kdump.Propose - @ret = { "raw_proposal" => Kdump.Summary } + + @ret = { + "raw_proposal" => Kdump.Summary, + # FATE#317488 When expectation at the end of proposal does not match + # the value, this proposal will be called again + "trigger" => { + "expect" => { + "class" => "Yast::Kdump", + "method" => "free_space_for_dump_b", + }, + "value" => Yast::Kdump.free_space_for_dump_b + } + } + + @ret.merge!(Kdump.proposal_warning) elsif @func == "AskUser" @has_next = Ops.get_boolean(@param, "has_next", false) @settings = Kdump.Export diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-kdump-3.1.22/src/modules/Kdump.rb new/yast2-kdump-3.1.24/src/modules/Kdump.rb --- old/yast2-kdump-3.1.22/src/modules/Kdump.rb 2015-06-01 16:39:08.000000000 +0200 +++ new/yast2-kdump-3.1.24/src/modules/Kdump.rb 2015-07-01 16:04:39.000000000 +0200 @@ -38,6 +38,10 @@ KDUMP_SERVICE_NAME = "kdump" KDUMP_PACKAGES = ["kexec-tools", "kdump"] + # Space on disk reserved for dump additionally to memory size in bytes + # @see FATE #317488 + RESERVED_DISK_SPACE_BUFFER_B = 4 * 1024**3 + def main textdomain "kdump" @@ -46,7 +50,6 @@ Yast.import "Summary" Yast.import "Message" Yast.import "BootCommon" - #import "Storage"; Yast.import "Map" Yast.import "Bootloader" Yast.import "Service" @@ -58,6 +61,7 @@ Yast.import "PackagesProposal" Yast.import "FileUtils" Yast.import "Directory" + Yast.import "String" # Data was modified? @modified = false @@ -66,8 +70,6 @@ @kdump_file = "/etc/sysconfig/kdump" - - @proposal_valid = false # List of available partiotions @@ -111,14 +113,12 @@ # string @kernel_version = "" - # Position actual boot section in BootCommon::sections list # it is relevant only if XEN boot section is used # # integer @section_pos = -1 - # Boolean option indicates kernel parameter # "crashkernel" # @@ -137,7 +137,6 @@ # boolean true if kernel parameter will be add @add_crashkernel_param = false - # String option for alocate of memory for boot param # "crashkernel" # @@ -151,7 +150,6 @@ @import_called = false - # Write only, used during autoinstallation. # Don't run services and SuSEconfig, it's all done at one place. @write_only = false @@ -207,7 +205,6 @@ @modified end - # Set data was modified def SetModified @modified = true @@ -282,7 +279,6 @@ end end - # get allocated memory from value of crashkernel option # there can be several ranges -> take the first range # @param string 64M@16M or 128M-:64M@16M [(reserved_memory*2)-:reserved_memory] @@ -440,6 +436,11 @@ true end + # Returns total size of physical memory in MiB + def total_memory + ReadAvailableMemory() if @total_memory.zero? + @total_memory + end def log_settings_censoring_passwords(message) debug_KDUMP_SETTINGS = deep_copy(@KDUMP_SETTINGS) @@ -752,7 +753,7 @@ def ProposeCrashkernelParam ReadAvailableMemory() # propose disable kdump if PC has less than 1024MB RAM - if @total_memory < 1024 + if total_memory < 1024 false else true @@ -880,6 +881,103 @@ deep_copy(result) end + # Returns available space (in bytes) for Kernel dump according to KDUMP_SAVEDIR option + # only local space is evaluated (starts with file://) + # + # @return [Integer] free space in bytes or nil if filesystem is not local or no + # packages proposal is made yet + def free_space_for_dump_b + kdump_savedir = @KDUMP_SETTINGS.fetch("KDUMP_SAVEDIR", "file:///var/log/dump") + log.info "Using savedir #{kdump_savedir}" + + if kdump_savedir.start_with?("/") + log.warn "Using old format" + elsif kdump_savedir.start_with?("file://") + kdump_savedir.sub!(/file:\/\//, "") + else + log.info "KDUMP_SAVEDIR #{kdump_savedir.inspect} is not local" + return nil + end + + # unified format of directory + kdump_savedir = format_dirname(kdump_savedir) + + partitions_info = SpaceCalculation.GetPartitionInfo() + if partitions_info.empty? + log.warn "No partitions info available" + return nil + end + + log.info "Disk usage: #{partitions_info}" + # Create a hash of partitions and their free space { partition => free_space, ... } + # "name" usually does not start with "/", but does so for root filesystem + # File.join ensures that paths do not contain dulplicit "/" characters + partitions_info = partitions_info.map do |partition| + { format_dirname(partition["name"]) => partition["free"] } + end.inject(:merge) + + # All partitions matching KDUMP_SAVEDIR + matching_partitions = partitions_info.select do |partition, _space| + kdump_savedir.start_with?(partition) + end + + # The longest match + partition = matching_partitions.keys.sort_by{|partiton| partiton.length}.last + free_space = matching_partitions[partition] + + if free_space.nil? || !free_space.is_a?(::Integer) + log.warn "Available space for partition #{partition} not provided (#{free_space.inspect})" + return nil + end + + # packager counts in kB, we need bytes + free_space *= 1024 + log.info "Available space for dump: #{free_space} bytes in #{partition} directory" + + free_space + end + + # Returns disk space in bytes requested for kernel dump (as defined in FATE#317488) + # + # @return [Integer] bytes + def space_requested_for_dump_b + # Total memory is in MB, converting to bytes + total_memory * 1024**2 + RESERVED_DISK_SPACE_BUFFER_B + end + + # Returns installation proposal warning as part of the MakeProposal map result + # includes 'warning' and 'warning_level' keys + # + # @param returns [Hash] with warnings + def proposal_warning + return {} unless @add_crashkernel_param + + free_space = free_space_for_dump_b + requested_space = space_requested_for_dump_b + + log.info "Free: #{free_space}, requested: #{requested_space}" + return {} if free_space.nil? || requested_space.nil? + + warning = {} + + if free_space < requested_space + warning = { + "warning_level" => :warning, + # TRANSLATORS: warning message in installation proposal, + # do not translate %{requested} and %{available} - they are replaced with actual sizes later + "warning" => "<ul><li>" + _( + "Warning! There might not be enough free space. " + + "%{required} required, but only %{available} are available.") % { + required: String.FormatSizeWithPrecision(requested_space, 2, true), + available: String.FormatSizeWithPrecision(free_space, 2, true) + } + "</li></ul>" + } + end + + log.warn warning["warning"] if warning["warning"] + warning + end + # bnc# 480466 - fix problem with validation autoyast profil # Function filters keys for autoyast profil # @@ -982,6 +1080,14 @@ @initial_kdump_settings[FADUMP_KEY] != @KDUMP_SETTINGS[FADUMP_KEY] end +private + + # Returns unified directory name with leading and ending "/" + # for exact matching + def format_dirname(dirname) + "/#{dirname}/".gsub(/\/+/, "/") + end + publish :function => :GetModified, :type => "boolean ()" publish :function => :SetModified, :type => "void ()" publish :variable => :modified, :type => "boolean" @@ -989,7 +1095,7 @@ publish :variable => :available_partitions, :type => "list <string>" publish :variable => :propose_called, :type => "boolean" publish :variable => :uknown_fs_partitions, :type => "list <string>" - publish :variable => :total_memory, :type => "integer" + publish :function => :total_memory, :type => "integer ()" publish :variable => :crashkernel_list_ranges, :type => "boolean" publish :variable => :kdump_packages, :type => "list <string>" publish :variable => :crashkernel_param, :type => "boolean" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-kdump-3.1.22/test/kdump_test.rb new/yast2-kdump-3.1.24/test/kdump_test.rb --- old/yast2-kdump-3.1.22/test/kdump_test.rb 2015-06-01 16:39:08.000000000 +0200 +++ new/yast2-kdump-3.1.24/test/kdump_test.rb 2015-07-01 16:04:39.000000000 +0200 @@ -3,6 +3,7 @@ require_relative "./test_helper" Yast.import "Kdump" +Yast.import "SpaceCalculation" describe Yast::Kdump do # allocated_memory is a string in megabytes @@ -39,4 +40,123 @@ end end end + + let(:partition_info) do + [ + {"free"=>389318, "name"=>"/", "used"=>1487222}, + {"free"=>1974697, "name"=>"usr", "used"=>4227733}, + {"free"=>2974697, "name"=>"/var", "used"=>4227733}, + # this is the matching partition entry + {"free"=>8974697, "name"=>"var/crash", "used"=>16}, + {"free"=>397697, "name"=>"var/crash/not-this", "used"=>455} + ] + end + + let(:not_exactly_matching_partition_info) do + [ + {"free"=>8888888, "name"=>"/"}, + {"free" => 1, "name" => "var/some"}, + {"free"=>5555555, "name"=>"somewhere/d"}, + {"free"=>6666666, "name"=>"somewhere/deep"} + ] + end + + describe "#free_space_for_dump_b" do + before do + allow(Yast::SpaceCalculation).to receive(:GetPartitionInfo).and_return(partition_info) + Yast::Kdump.KDUMP_SETTINGS["KDUMP_SAVEDIR"] = "file:///var/crash" + end + + context "when dump location is local" do + it "returns space on disk in bytes available for kernel dump" do + # partition info counts in kB, we us bytes + expect(Yast::Kdump.free_space_for_dump_b).to eq(8974697 * 1024) + end + end + + context "when dump location is not local" do + it "returns 'nil'" do + Yast::Kdump.KDUMP_SETTINGS["KDUMP_SAVEDIR"] = "nfs://server/export/var/log/dump" + expect(Yast::Kdump.free_space_for_dump_b).to eq(nil) + + Yast::Kdump.KDUMP_SETTINGS["KDUMP_SAVEDIR"] = "ssh://user:password@host/var/log/dump" + expect(Yast::Kdump.free_space_for_dump_b).to eq(nil) + end + end + + context "when empty partition info is available" do + it "returns 'nil'" do + allow(Yast::SpaceCalculation).to receive(:GetPartitionInfo).and_return([]) + expect(Yast::Kdump.free_space_for_dump_b).to eq(nil) + end + end + + context "when partition does not provide free space information" do + it "returns 'nil'" do + allow(Yast::SpaceCalculation).to receive(:GetPartitionInfo).and_return([{"free"=>nil, "name"=>"var/crash"}]) + expect(Yast::Kdump.free_space_for_dump_b).to eq(nil) + + allow(Yast::SpaceCalculation).to receive(:GetPartitionInfo).and_return([{"name"=>"var/crash"}]) + expect(Yast::Kdump.free_space_for_dump_b).to eq(nil) + end + end + + context "when partition info does not exactly match directory for dump" do + it "returns space on disk (in mountpoint above) in bytes available for kernel dump" do + Yast::Kdump.KDUMP_SETTINGS["KDUMP_SAVEDIR"] = "file:///var/crash" + allow(Yast::SpaceCalculation).to receive(:GetPartitionInfo).and_return(not_exactly_matching_partition_info) + expect(Yast::Kdump.free_space_for_dump_b).to eq(8888888 * 1024) + + Yast::Kdump.KDUMP_SETTINGS["KDUMP_SAVEDIR"] = "file:///somewhere/deep/in/filesystem/" + allow(Yast::SpaceCalculation).to receive(:GetPartitionInfo).and_return(not_exactly_matching_partition_info) + expect(Yast::Kdump.free_space_for_dump_b).to eq(6666666 * 1024) + end + end + end + + # in MB! + let(:total_memory_size_mb) { 8 * 1024 } + + describe "#space_requested_for_dump_b" do + it "returns space in bytes requested for kernel dump" do + allow(Yast::Kdump).to receive(:total_memory).and_return(total_memory_size_mb) + + expect(Yast::Kdump.space_requested_for_dump_b).to eq(total_memory_size_mb * 1024**2 + 4 * 1024**3) + end + end + + describe "#proposal_warning" do + before do + allow(Yast::Kdump).to receive(:space_requested_for_dump_b).and_return(4 * 1024**3) + Yast::Kdump.instance_variable_set("@add_crashkernel_param", true) + end + + context "when kdump is not enabled" do + it "returns empty hash" do + Yast::Kdump.instance_variable_set("@add_crashkernel_param", false) + + warning = Yast::Kdump.proposal_warning + expect(warning).to eq({}) + end + end + + context "when free space is smaller than requested" do + it "returns hash with warning and warning_level keys" do + allow(Yast::Kdump).to receive(:free_space_for_dump_b).and_return(3978 * 1024**2) + + warning = Yast::Kdump.proposal_warning + expect(warning["warning"]).to match(/There might not be enough free space.*only.*are available/) + expect(warning["warning_level"]).not_to eq(nil) + end + end + + context "when free space is bigger or equal to requested size" do + it "returns empty hash" do + allow(Yast::Kdump).to receive(:free_space_for_dump_b).and_return(120 * 1024**3) + + warning = Yast::Kdump.proposal_warning + expect(warning).to eq({}) + end + end + end end