Skip to content

Commit

Permalink
Merge pull request #1152 from shundhammer/huha-ignore-probe-errors-ma…
Browse files Browse the repository at this point in the history
…ster

L3 Veritas Volume Manager: Allow to Ignore Probe Errors (master)
  • Loading branch information
shundhammer committed Oct 22, 2020
2 parents 5f7bd5d + 0ff64f5 commit e505276
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
6 changes: 6 additions & 0 deletions package/yast2-storage-ng.changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
Tue Oct 20 15:36:03 UTC 2020 - Stefan Hundhammer <shundhammer@suse.com>

- Added $LIBSTORAGE_IGNORE_PROBE_ERRORS environment variable
to ignore storage probing errors (bsc#1177332)
- 4.3.16
-------------------------------------------------------------------
Wed Aug 26 10:08:03 UTC 2020 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Unify profile element paths (bsc#1175680).
Expand Down
2 changes: 1 addition & 1 deletion package/yast2-storage-ng.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-storage-ng
Version: 4.3.15
Version: 4.3.16
Release: 0
Summary: YaST2 - Storage Configuration
License: GPL-2.0-only OR GPL-3.0-only
Expand Down
25 changes: 25 additions & 0 deletions src/lib/y2storage/callbacks/probe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,31 @@ module Callbacks
class Probe < Storage::ProbeCallbacksV3
include LibstorageCallback

# Callback for libstorage-ng to report an error to the user.
#
# If the $LIBSTORAGE_IGNORE_PROBE_ERRORS environment variable is set,
# this just returns 'true', i.e. the error is ignored.
#
# Otherwise, this displays the error and prompts the user if the error
# should be ignored.
#
# @note If the user rejects to continue, the method will return false
# which implies libstorage-ng will raise the corresponding exception for
# the error.
#
# See Storage::Callbacks#error in libstorage-ng
#
# @param message [String] error title coming from libstorage-ng
# (in the ASCII-8BIT encoding! see https://sourceforge.net/p/swig/feature-requests/89/)
# @param what [String] details coming from libstorage-ng (in the ASCII-8BIT encoding!)
# @return [Boolean] true will make libstorage-ng ignore the error, false
# will result in a libstorage-ng exception
def error(message, what)
return true if StorageEnv.instance.ignore_probe_errors?

super(message, what)
end

# Callback for missing commands during probing.
#
# @param message [String] error title coming from libstorage-ng
Expand Down
18 changes: 18 additions & 0 deletions src/lib/y2storage/storage_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ class StorageEnv

ENV_ACTIVATE_LUKS = "YAST_ACTIVATE_LUKS".freeze

ENV_LIBSTORAGE_IGNORE_PROBE_ERRORS = "LIBSTORAGE_IGNORE_PROBE_ERRORS".freeze

private_constant :ENV_MULTIPATH, :ENV_BIOS_RAID, :ENV_ACTIVATE_LUKS
private_constant :ENV_LIBSTORAGE_IGNORE_PROBE_ERRORS

def initialize
@active_cache = {}
Expand Down Expand Up @@ -67,6 +70,21 @@ def activate_luks?
active?(ENV_ACTIVATE_LUKS, true)
end

# Whether errors during libstorage probing should be ignored.
#
# See bsc#1177332:
#
# Some storage technologies like Veritas Volume Manager use disk labels
# like "sun" that we don't support in libstorage / storage-ng. Setting the
# LIBSTORAGE_IGNORE_PROBE_ERRORS env var gives the admin a chance to use
# the YaST partitioner despite that. Those disks will show up like empty
# disks and not cause an error pop-up for each one.
def ignore_probe_errors?
result = active?(ENV_LIBSTORAGE_IGNORE_PROBE_ERRORS)
log.info("Ignoring libstorage probe errors") if result
result
end

private

# Whether the env variable is active
Expand Down
19 changes: 19 additions & 0 deletions test/y2storage/callbacks/probe_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@
describe "#error" do
include_examples "general #error examples"
include_examples "default #error true examples"

context "without LIBSTORAGE_IGNORE_PROBE_ERRORS" do
before { mock_env(env_vars) }
let(:env_vars) { {} }
it "it displays an error pop-up" do
expect(Yast::Report).to receive(:yesno_popup)
subject.error("probing failed", "")
end
end

context "with LIBSTORAGE_IGNORE_PROBE_ERRORS set" do
before { mock_env(env_vars) }
after { mock_env({}) } # clean up for future tests
let(:env_vars) { { "LIBSTORAGE_IGNORE_PROBE_ERRORS" => "1" } }
it "does not display an error pop-up and returns true" do
expect(Yast::Report).not_to receive(:yesno_popup)
expect(subject.error("probing failed", "")).to be true
end
end
end

describe "#begin" do
Expand Down

0 comments on commit e505276

Please sign in to comment.