Skip to content

Commit e505276

Browse files
authored
Merge pull request #1152 from shundhammer/huha-ignore-probe-errors-master
L3 Veritas Volume Manager: Allow to Ignore Probe Errors (master)
2 parents 5f7bd5d + 0ff64f5 commit e505276

5 files changed

Lines changed: 69 additions & 1 deletion

File tree

package/yast2-storage-ng.changes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
-------------------------------------------------------------------
2+
Tue Oct 20 15:36:03 UTC 2020 - Stefan Hundhammer <shundhammer@suse.com>
3+
4+
- Added $LIBSTORAGE_IGNORE_PROBE_ERRORS environment variable
5+
to ignore storage probing errors (bsc#1177332)
6+
- 4.3.16
7+
-------------------------------------------------------------------
28
Wed Aug 26 10:08:03 UTC 2020 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>
39

410
- Unify profile element paths (bsc#1175680).

package/yast2-storage-ng.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#
1717

1818
Name: yast2-storage-ng
19-
Version: 4.3.15
19+
Version: 4.3.16
2020
Release: 0
2121
Summary: YaST2 - Storage Configuration
2222
License: GPL-2.0-only OR GPL-3.0-only

src/lib/y2storage/callbacks/probe.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,31 @@ module Callbacks
3131
class Probe < Storage::ProbeCallbacksV3
3232
include LibstorageCallback
3333

34+
# Callback for libstorage-ng to report an error to the user.
35+
#
36+
# If the $LIBSTORAGE_IGNORE_PROBE_ERRORS environment variable is set,
37+
# this just returns 'true', i.e. the error is ignored.
38+
#
39+
# Otherwise, this displays the error and prompts the user if the error
40+
# should be ignored.
41+
#
42+
# @note If the user rejects to continue, the method will return false
43+
# which implies libstorage-ng will raise the corresponding exception for
44+
# the error.
45+
#
46+
# See Storage::Callbacks#error in libstorage-ng
47+
#
48+
# @param message [String] error title coming from libstorage-ng
49+
# (in the ASCII-8BIT encoding! see https://sourceforge.net/p/swig/feature-requests/89/)
50+
# @param what [String] details coming from libstorage-ng (in the ASCII-8BIT encoding!)
51+
# @return [Boolean] true will make libstorage-ng ignore the error, false
52+
# will result in a libstorage-ng exception
53+
def error(message, what)
54+
return true if StorageEnv.instance.ignore_probe_errors?
55+
56+
super(message, what)
57+
end
58+
3459
# Callback for missing commands during probing.
3560
#
3661
# @param message [String] error title coming from libstorage-ng

src/lib/y2storage/storage_env.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ class StorageEnv
3232

3333
ENV_ACTIVATE_LUKS = "YAST_ACTIVATE_LUKS".freeze
3434

35+
ENV_LIBSTORAGE_IGNORE_PROBE_ERRORS = "LIBSTORAGE_IGNORE_PROBE_ERRORS".freeze
36+
3537
private_constant :ENV_MULTIPATH, :ENV_BIOS_RAID, :ENV_ACTIVATE_LUKS
38+
private_constant :ENV_LIBSTORAGE_IGNORE_PROBE_ERRORS
3639

3740
def initialize
3841
@active_cache = {}
@@ -67,6 +70,21 @@ def activate_luks?
6770
active?(ENV_ACTIVATE_LUKS, true)
6871
end
6972

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

7290
# Whether the env variable is active

test/y2storage/callbacks/probe_test.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@
2828
describe "#error" do
2929
include_examples "general #error examples"
3030
include_examples "default #error true examples"
31+
32+
context "without LIBSTORAGE_IGNORE_PROBE_ERRORS" do
33+
before { mock_env(env_vars) }
34+
let(:env_vars) { {} }
35+
it "it displays an error pop-up" do
36+
expect(Yast::Report).to receive(:yesno_popup)
37+
subject.error("probing failed", "")
38+
end
39+
end
40+
41+
context "with LIBSTORAGE_IGNORE_PROBE_ERRORS set" do
42+
before { mock_env(env_vars) }
43+
after { mock_env({}) } # clean up for future tests
44+
let(:env_vars) { { "LIBSTORAGE_IGNORE_PROBE_ERRORS" => "1" } }
45+
it "does not display an error pop-up and returns true" do
46+
expect(Yast::Report).not_to receive(:yesno_popup)
47+
expect(subject.error("probing failed", "")).to be true
48+
end
49+
end
3150
end
3251

3352
describe "#begin" do

0 commit comments

Comments
 (0)