main - lvmdbusd: Correct typos
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ec50979b031e85ab155...
Commit: ec50979b031e85ab155126aae51ab15b255f4be9
Parent: 3d8882db833909bede4b8cbcc81c1c3b9d9b3515
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Tue Aug 23 10:24:37 2022 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Sep 16 10:49:37 2022 -0500
lvmdbusd: Correct typos
---
daemons/lvmdbusd/lvmdb.py.in | 2 +-
test/dbus/lvmdbustest.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmdbusd/lvmdb.py.in b/daemons/lvmdbusd/lvmdb.py.in
index 87474d0f3..d462e0cf8 100644
--- a/daemons/lvmdbusd/lvmdb.py.in
+++ b/daemons/lvmdbusd/lvmdb.py.in
@@ -161,7 +161,7 @@ class DataStore(object):
c_lvs = OrderedDict()
c_lv_full_lookup = {}
- # Each item item in the report is a collection of information pertaining
+ # Each item in the report is a collection of information pertaining
# to the vg
for r in _all['report']:
# Get the lv data for this VG.
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 878300a97..c4e95b7cc 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -215,7 +215,7 @@ class TestDbusService(unittest.TestCase):
def setUp(self):
# Because of the sensitive nature of running LVM tests we will only
# run if we have PVs and nothing else, so that we can be confident that
- # we are not mucking with someones data on their system
+ # we are not mucking with someone's data on their system
self.objs, self.bus = get_objects()
if len(self.objs[PV_INT]) == 0:
std_err_print('No PVs present exiting!')
6 months, 1 week
main - lvmdbusd: fix hangs on SIGINT
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3d8882db833909bede4...
Commit: 3d8882db833909bede4b8cbcc81c1c3b9d9b3515
Parent: f4cb78a4e1ac2cf7cc30d76e86765618071b2813
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Aug 17 17:21:19 2022 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Sep 16 10:49:37 2022 -0500
lvmdbusd: fix hangs on SIGINT
Rather than trying to bubble up return codes that get us to exit cleanly
it's better to just raise an exception to bail. In some cases functions
don't have return codes, so they cannot be checked.
---
daemons/lvmdbusd/cmdhandler.py | 20 ++++++++++++------
daemons/lvmdbusd/fetch.py | 37 ++++++++++++++++++++++++----------
daemons/lvmdbusd/lvm_shell_proxy.py.in | 10 +++++++--
daemons/lvmdbusd/main.py | 1 +
4 files changed, 49 insertions(+), 19 deletions(-)
diff --git a/daemons/lvmdbusd/cmdhandler.py b/daemons/lvmdbusd/cmdhandler.py
index 0422f8970..b2d3077ad 100644
--- a/daemons/lvmdbusd/cmdhandler.py
+++ b/daemons/lvmdbusd/cmdhandler.py
@@ -6,7 +6,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
+import errno
from subprocess import Popen, PIPE
import select
import time
@@ -131,7 +131,7 @@ def call_lvm(command, debug=False, line_cb=None,
make_non_block(process.stdout)
make_non_block(process.stderr)
- while True:
+ while True and cfg.run.value != 0:
try:
rd_fd = [process.stdout.fileno(), process.stderr.fileno()]
ready = select.select(rd_fd, [], [], 2)
@@ -161,12 +161,20 @@ def call_lvm(command, debug=False, line_cb=None,
break
except IOError as ioe:
log_debug("call_lvm:" + str(ioe))
- pass
+ break
+
+ if process.returncode is not None:
+ if debug or process.returncode != 0:
+ _debug_c(command, process.returncode, (stdout_text, stderr_text))
- if debug or process.returncode != 0:
- _debug_c(command, process.returncode, (stdout_text, stderr_text))
+ return process.returncode, stdout_text, stderr_text
+ else:
+ if cfg.run.value == 0:
+ raise Exception("Daemon is exiting!")
+ # We can bail out before the lvm command finished when we get a signal
+ # which is requesting we exit
+ return -errno.EINTR, "", "operation interrupted"
- return process.returncode, stdout_text, stderr_text
# The actual method which gets called to invoke the lvm command, can vary
# from forking a new process to using lvm shell
diff --git a/daemons/lvmdbusd/fetch.py b/daemons/lvmdbusd/fetch.py
index 740b15fdb..f1e9104a8 100644
--- a/daemons/lvmdbusd/fetch.py
+++ b/daemons/lvmdbusd/fetch.py
@@ -120,8 +120,26 @@ class StateUpdate(object):
@staticmethod
def update_thread(obj):
exception_count = 0
-
queued_requests = []
+
+ def set_results(val):
+ nonlocal queued_requests
+ for idx in queued_requests:
+ idx.set_result(val)
+ # Only clear out the requests after we have given them a result
+ # otherwise we can orphan the waiting threads, and they never
+ # wake up if we get an exception
+ queued_requests = []
+
+ def bailing(rv):
+ set_results(rv)
+ try:
+ while True:
+ item = obj.queue.get(False)
+ item.set_result(rv)
+ except queue.Empty:
+ pass
+
while cfg.run.value != 0:
# noinspection PyBroadException
try:
@@ -167,13 +185,7 @@ class StateUpdate(object):
num_changes = load(refresh, emit_signal, cache_refresh, log,
need_main_thread)
# Update is done, let everyone know!
- for i in queued_requests:
- i.set_result(num_changes)
-
- # Only clear out the requests after we have given them a result
- # otherwise we can orphan the waiting threads and they never
- # wake up if we get an exception
- queued_requests = []
+ set_results(num_changes)
# We retrieved OK, clear exception count
exception_count = 0
@@ -186,9 +198,7 @@ class StateUpdate(object):
cfg.flightrecorder.dump()
exception_count += 1
if exception_count >= 5:
- for i in queued_requests:
- i.set_result(e)
-
+ bailing(e)
log_error("Too many errors in update_thread, exiting daemon")
cfg.exit_daemon()
@@ -196,6 +206,11 @@ class StateUpdate(object):
# Slow things down when encountering errors
time.sleep(1)
+ # Make sure to unblock any that may be waiting before we exit this thread
+ # otherwise they hang forever ...
+ bailing(Exception("update thread exiting"))
+ log_debug("update thread exiting!")
+
def __init__(self):
self.lock = threading.RLock()
self.queue = queue.Queue()
diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py.in b/daemons/lvmdbusd/lvm_shell_proxy.py.in
index 43609047b..ebab57e97 100644
--- a/daemons/lvmdbusd/lvm_shell_proxy.py.in
+++ b/daemons/lvmdbusd/lvm_shell_proxy.py.in
@@ -26,7 +26,7 @@ except ImportError:
import json
-from lvmdbusd.cfg import LVM_CMD
+from lvmdbusd.cfg import LVM_CMD, run
from lvmdbusd.utils import log_debug, log_error, add_no_notify, make_non_block,\
read_decoded
@@ -57,7 +57,7 @@ class LVMShellProxy(object):
# a hang. Keep reading until we get the prompt back and the report
# FD does not contain valid JSON
- while keep_reading:
+ while keep_reading and run.value != 0:
try:
rd_fd = [
self.lvm_shell.stdout.fileno(),
@@ -230,6 +230,12 @@ class LVMShellProxy(object):
log_error(("EC = %d" % rc))
log_error(("ERROR_MSG=\n %s\n" % error_msg))
+ if run.value == 0:
+ # Try to clean up lvm shelll process
+ log_debug("exiting lvm shell as we are shutting down")
+ self.exit_shell()
+ raise Exception("Daemon is exiting!")
+
return rc, report_json, error_msg
def exit_shell(self):
diff --git a/daemons/lvmdbusd/main.py b/daemons/lvmdbusd/main.py
index 5369f1dd5..dc6aa2277 100644
--- a/daemons/lvmdbusd/main.py
+++ b/daemons/lvmdbusd/main.py
@@ -53,6 +53,7 @@ def process_request():
except Exception:
st = traceback.format_exc()
utils.log_error("process_request exception: \n%s" % st)
+ log_debug("process_request thread exiting!")
def check_fr_size(value):
6 months, 1 week
main - lvmdbustest: Add test removing incomplete job
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f4cb78a4e1ac2cf7cc3...
Commit: f4cb78a4e1ac2cf7cc30d76e86765618071b2813
Parent: 2ca4a2dbf3d35528f8173916aed77fd277f23f18
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Aug 17 12:14:02 2022 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Sep 16 10:49:37 2022 -0500
lvmdbustest: Add test removing incomplete job
When you try to remove a job that is incomplete you get a dbus exception.
Test for this error condition.
---
test/dbus/lvmdbustest.py | 38 ++++++++++++++++++++++++++++++--------
1 file changed, 30 insertions(+), 8 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index d67298fe9..878300a97 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -1115,13 +1115,7 @@ class TestDbusService(unittest.TestCase):
vg_path = self._wait_for_job(vg_job)
self._validate_lookup(vg_name, vg_path)
- def _test_expired_timer(self, num_lvs):
- rc = False
-
- # In small configurations lvm is pretty snappy, so let's create a VG
- # add a number of LVs and then remove the VG and all the contained
- # LVs which appears to consistently run a little slow.
-
+ def _create_num_lvs(self, num_lvs):
vg_proxy = self._vg_create(self._all_pv_object_paths())
for i in range(0, num_lvs):
@@ -1140,8 +1134,18 @@ class TestDbusService(unittest.TestCase):
"%s/%s" % (vg_proxy.Vg.Name, lv_name), lv_path)
else:
- # We ran out of space, test will probably fail
+ # We ran out of space, test(s) may fail
break
+ return vg_proxy
+
+ def _test_expired_timer(self, num_lvs):
+ rc = False
+
+ # In small configurations lvm is pretty snappy, so let's create a VG
+ # add a number of LVs and then remove the VG and all the contained
+ # LVs which appears to consistently run a little slow.
+
+ vg_proxy = self._create_num_lvs(num_lvs)
# Make sure that we are honoring the timeout
start = time.time()
@@ -2105,6 +2109,24 @@ class TestDbusService(unittest.TestCase):
self.assertTrue(rc == 0)
self._log_file_option()
+ def test_delete_non_complete_job(self):
+ # Let's create a vg with a number of lvs and then delete it all
+ # to hopefully create a long-running job.
+ vg_proxy = self._create_num_lvs(64)
+ job_path = vg_proxy.Vg.Remove(dbus.Int32(0), EOD)
+ self.assertNotEqual(job_path, "/")
+
+ # Try to delete the job expecting an exception
+ job_proxy = ClientProxy(self.bus, job_path, interfaces=(JOB_INT,)).Job
+ with self.assertRaises(dbus.exceptions.DBusException):
+ try:
+ job_proxy.Remove()
+ except dbus.exceptions.DBusException as e:
+ # Verify we got the expected text in exception
+ self.assertTrue('Job is not complete!' in str(e))
+ raise e
+
+
class AggregateResults(object):
def __init__(self):
6 months, 1 week
main - lvmdbustest: Add test for external event
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2ca4a2dbf3d35528f81...
Commit: 2ca4a2dbf3d35528f8173916aed77fd277f23f18
Parent: 4a202c11fffb30ae786e69cebe11186dd4166c88
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Aug 17 12:12:17 2022 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Sep 16 10:49:37 2022 -0500
lvmdbustest: Add test for external event
Ensure that when we trigger an external event that we don't incorrectly
handle multiple --config options.
---
test/dbus/lvmdbustest.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index c03e96c08..d67298fe9 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -2095,6 +2095,16 @@ class TestDbusService(unittest.TestCase):
def test_log_file_option(self):
self._log_file_option()
+ def test_external_event(self):
+ # Call into the service to register an external event, so that we can test sending the path
+ # where we don't send notifications on the command line in addition to the logging
+ lvm_manager = dbus.Interface(bus.get_object(
+ BUS_NAME, "/com/redhat/lvmdbus1/Manager", introspect=False),
+ "com.redhat.lvmdbus1.Manager")
+ rc = lvm_manager.ExternalEvent("unit_test")
+ self.assertTrue(rc == 0)
+ self._log_file_option()
+
class AggregateResults(object):
def __init__(self):
6 months, 1 week
main - lvmdbustest: Add test for passing log file in options
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4a202c11fffb30ae786...
Commit: 4a202c11fffb30ae786e69cebe11186dd4166c88
Parent: 60e4ba36e0843c9536278ff33ce6dfda9cfd8079
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Aug 17 12:11:07 2022 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Sep 16 10:49:37 2022 -0500
lvmdbustest: Add test for passing log file in options
---
test/dbus/lvmdbustest.py | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 4977021b1..c03e96c08 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -340,11 +340,14 @@ class TestDbusService(unittest.TestCase):
self.assertTrue(rc is not None and len(rc) > 0)
self._check_consistency()
- def _vg_create(self, pv_paths=None, vg_prefix=None):
+ def _vg_create(self, pv_paths=None, vg_prefix=None, options=None):
if not pv_paths:
pv_paths = self._all_pv_object_paths()
+ if options is None:
+ options = EOD
+
vg_name = vg_n(prefix=vg_prefix)
vg_path = self.handle_return(
@@ -352,7 +355,7 @@ class TestDbusService(unittest.TestCase):
dbus.String(vg_name),
dbus.Array(pv_paths, signature=dbus.Signature('o')),
dbus.Int32(g_tmo),
- EOD))
+ options))
self._validate_lookup(vg_name, vg_path)
self.assertTrue(vg_path is not None and len(vg_path) > 0)
@@ -2077,6 +2080,20 @@ class TestDbusService(unittest.TestCase):
self._test_lv_method_interface_sequence(
self._vdo_pool_lv(), test_ss=False)
+ def _log_file_option(self):
+ fn = "/tmp/%s" % rs(8, "_lvm.log")
+ try:
+ options = dbus.Dictionary({}, signature=dbus.Signature('sv'))
+ option_str = "log { level=7 file=%s syslog=0 }" % fn
+ options["config"] = dbus.String(option_str)
+ self._vg_create(None, None, options)
+ self.assertTrue(os.path.exists(fn))
+ finally:
+ if os.path.exists(fn):
+ os.unlink(fn)
+
+ def test_log_file_option(self):
+ self._log_file_option()
class AggregateResults(object):
6 months, 1 week
main - lvmdbusd: Remove unused locking functionality
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=60e4ba36e0843c95362...
Commit: 60e4ba36e0843c9536278ff33ce6dfda9cfd8079
Parent: cfc87157a4fdec39c2b570bd35ce812cda3003f6
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Aug 17 12:09:30 2022 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Sep 16 10:49:37 2022 -0500
lvmdbusd: Remove unused locking functionality
I don't think we have ever utilized this, remove.
---
daemons/lvmdbusd/objectmanager.py | 35 -----------------------------------
1 file changed, 35 deletions(-)
diff --git a/daemons/lvmdbusd/objectmanager.py b/daemons/lvmdbusd/objectmanager.py
index 95d33db19..a0c4a50ef 100644
--- a/daemons/lvmdbusd/objectmanager.py
+++ b/daemons/lvmdbusd/objectmanager.py
@@ -53,15 +53,6 @@ class ObjectManager(AutomatedProperties):
(self, ), cb, cbe, False)
cfg.worker_q.put(r)
- def locked(self):
- """
- If some external code need to run across a number of different
- calls into ObjectManager while blocking others they can use this method
- to lock others out.
- :return:
- """
- return ObjectManagerLock(self.rlock)
-
@dbus.service.signal(
dbus_interface="org.freedesktop.DBus.ObjectManager",
signature='oa{sa{sv}}')
@@ -337,29 +328,3 @@ class ObjectManager(AutomatedProperties):
# (uuid, lvm_id, str(path_create), path))
return path
-
-
-class ObjectManagerLock(object):
- """
- The sole purpose of this class is to allow other code the ability to
- lock the object manager using a `with` statement, eg.
-
- with cfg.om.locked():
- # Do stuff with object manager
-
- This will ensure that the lock is always released (assuming this is done
- correctly)
- """
-
- def __init__(self, recursive_lock):
- self._lock = recursive_lock
-
- def __enter__(self):
- # Acquire lock
- self._lock.acquire()
-
- # noinspection PyUnusedLocal
- def __exit__(self, e_type, e_value, e_traceback):
- # Release lock
- self._lock.release()
- self._lock = None
6 months, 1 week
main - lvmdbusd: Make sure to set cfg.got_external_event
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cfc87157a4fdec39c2b...
Commit: cfc87157a4fdec39c2b570bd35ce812cda3003f6
Parent: 068073e924246ebda66b6dff590455d648007007
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Aug 17 12:08:16 2022 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Sep 16 10:49:37 2022 -0500
lvmdbusd: Make sure to set cfg.got_external_event
We were incorrectly only setting this if --udev wasn't present on the
command line. In all cases when we see a manager.ExternalEvent we want
to set this.
---
daemons/lvmdbusd/manager.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/daemons/lvmdbusd/manager.py b/daemons/lvmdbusd/manager.py
index e6b0718c4..45e7bb0b8 100644
--- a/daemons/lvmdbusd/manager.py
+++ b/daemons/lvmdbusd/manager.py
@@ -194,6 +194,7 @@ class Manager(AutomatedProperties):
def _external_event(command):
utils.log_debug("Processing _external_event= %s" % command,
'bg_black', 'fg_orange')
+ cfg.got_external_event = True
cfg.load()
@dbus.service.method(
@@ -204,11 +205,9 @@ class Manager(AutomatedProperties):
# If a user didn't explicitly specify udev, we will turn it off now.
if not cfg.args.use_udev:
if udevwatch.remove():
- utils.log_debug("ExternalEvent received, disabling "
+ utils.log_msg("ExternalEvent received, disabling "
"udev monitoring")
# We are dependent on external events now to stay current!
- cfg.got_external_event = True
-
r = RequestEntry(
-1, Manager._external_event, (command,), None, None, False)
cfg.worker_q.put(r)
6 months, 1 week
main - lvmdbusd: Correct typos
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=068073e924246ebda66...
Commit: 068073e924246ebda66b6dff590455d648007007
Parent: abf22df46c53968e5b064b2a4feb7b57e08fac09
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Aug 17 12:06:17 2022 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Sep 16 10:49:36 2022 -0500
lvmdbusd: Correct typos
---
daemons/lvmdbusd/objectmanager.py | 4 ++--
daemons/lvmdbusd/utils.py | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/daemons/lvmdbusd/objectmanager.py b/daemons/lvmdbusd/objectmanager.py
index e40e9a14a..95d33db19 100644
--- a/daemons/lvmdbusd/objectmanager.py
+++ b/daemons/lvmdbusd/objectmanager.py
@@ -287,7 +287,7 @@ class ObjectManager(AutomatedProperties):
register it with the object manager for the specified uuid & lvm_id.
Note: If path create is not None, uuid and lvm_id cannot be equal
:param uuid: The uuid for the lvm object we are searching for
- :param lvm_id: The lvm name (eg. pv device path, vg name, lv full name)
+ :param lvm_id: The lvm name (e.g. pv device path, vg name, lv full name)
:param path_create: If not None, create the path using this function if
we fail to find the object by uuid or lvm_id.
:returns None if lvm asset not found and path_create == None otherwise
@@ -308,7 +308,7 @@ class ObjectManager(AutomatedProperties):
# We have a uuid and a lvm_id we can do sanity checks to ensure
# that they are consistent
- # If a PV is missing it's device path is '[unknown]' or some
+ # If a PV is missing its device path is '[unknown]' or some
# other text derivation of unknown. When we find that a PV is
# missing we will clear out the lvm_id as it's likely not unique
# and thus not useful and potentially harmful for lookups.
diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py
index e12c7fccf..75a5348f5 100644
--- a/daemons/lvmdbusd/utils.py
+++ b/daemons/lvmdbusd/utils.py
@@ -593,7 +593,7 @@ def add_no_notify(cmdline):
:rtype: list
"""
- # Only after we have seen an external event will be disable lvm from sending
+ # Only after we have seen an external event will we disable lvm from sending
# us one when we call lvm
if cfg.got_external_event:
if 'help' in cmdline:
@@ -612,8 +612,8 @@ def add_no_notify(cmdline):
# The methods below which start with mt_* are used to execute the desired code
-# on the the main thread of execution to alleviate any issues the dbus-python
-# library with regards to multi-threaded access. Essentially, we are trying to
+# on the main thread of execution to alleviate any issues the dbus-python
+# library with regard to multithreaded access. Essentially, we are trying to
# ensure all dbus library interaction is done from the same thread!
6 months, 1 week
main - lvmdbusd: Handle no lastlog
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=abf22df46c53968e5b0...
Commit: abf22df46c53968e5b064b2a4feb7b57e08fac09
Parent: cef3c75dd496961cf7f2d2509fd694b9edf28421
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Aug 17 12:05:06 2022 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Sep 16 10:49:36 2022 -0500
lvmdbusd: Handle no lastlog
Depending on when an occurs, it maynot have any information available for
lastlog. In this case try to grab an error message from the original
response.
---
daemons/lvmdbusd/lvm_shell_proxy.py.in | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py.in b/daemons/lvmdbusd/lvm_shell_proxy.py.in
index 5802d2d70..43609047b 100644
--- a/daemons/lvmdbusd/lvm_shell_proxy.py.in
+++ b/daemons/lvmdbusd/lvm_shell_proxy.py.in
@@ -164,12 +164,14 @@ class LVMShellProxy(object):
os.unlink(tmp_file)
os.rmdir(tmp_dir)
- def get_error_msg(self):
- # We got an error, lets go fetch the error message
+ def get_last_log(self):
self._write_cmd('lastlog\n')
+ report_json= self._read_response()[1]
+ return LVMShellProxy.get_error_msg(report_json)
- # read everything from the STDOUT to the next prompt
- stdout, report_json, stderr = self._read_response()
+ @staticmethod
+ def get_error_msg(report_json):
+ # Get the error message from the returned JSON
if 'log' in report_json:
error_msg = ""
# Walk the entire log array and build an error string
@@ -182,7 +184,7 @@ class LVMShellProxy(object):
return error_msg
- return 'No error reason provided! (missing "log" section)'
+ return None
def call_lvm(self, argv, debug=False):
rc = 1
@@ -210,10 +212,18 @@ class LVMShellProxy(object):
ret_code = int(report_json['log'][-1:][0]['log_ret_code'])
# If we have an exported vg we get a log_ret_code == 5 when
# we do a 'fullreport'
+ # Note: 0 == error
if (ret_code == 1) or (ret_code == 5 and argv[0] == 'fullreport'):
rc = 0
else:
- error_msg = self.get_error_msg()
+ # Depending on where lvm fails the command, it may not have anything
+ # to report for "lastlog", so we need to check for a message in the
+ # report json too.
+ error_msg = self.get_last_log()
+ if error_msg is None:
+ error_msg = LVMShellProxy.get_error_msg(report_json)
+ if error_msg is None:
+ error_msg = 'No error reason provided! (missing "log" section)'
if debug or rc != 0:
log_error(('CMD: %s' % cmd))
6 months, 1 week
main - lvmdbustest: nesting improvements
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cef3c75dd496961cf7f...
Commit: cef3c75dd496961cf7f2d2509fd694b9edf28421
Parent: 6b9cc7432ec70461217c081b5d38065236aec887
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Aug 10 13:59:11 2022 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Sep 16 10:49:36 2022 -0500
lvmdbustest: nesting improvements
---
test/dbus/lvmdbustest.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index e7df238ce..4977021b1 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -1827,8 +1827,8 @@ class TestDbusService(unittest.TestCase):
cmd = ['pvcreate', target.Pv.Name]
self._verify_existence(cmd, cmd[0], target.Pv.Name)
- def _create_nested(self, pv_object_path):
- vg = self._vg_create([pv_object_path])
+ def _create_nested(self, pv_object_path, vg_suffix):
+ vg = self._vg_create([pv_object_path], vg_suffix)
pv = ClientProxy(self.bus, pv_object_path, interfaces=(PV_INT,))
self.assertEqual(pv.Pv.Vg, vg.object_path)
@@ -1838,8 +1838,12 @@ class TestDbusService(unittest.TestCase):
lv = self._create_lv(
vg=vg.Vg, size=vg.Vg.FreeBytes, suffix="_pv0")
device_path = '/dev/%s/%s' % (vg.Vg.Name, lv.LvCommon.Name)
+ dev_info = os.stat(device_path)
+ major = os.major(dev_info.st_rdev)
+ minor = os.minor(dev_info.st_rdev)
+ sysfs = "/sys/dev/block/%d:%d" % (major, minor)
+ self.assertTrue(os.path.exists(sysfs))
new_pv_object_path = self._pv_create(device_path)
-
vg.update()
self.assertEqual(lv.LvCommon.Vg, vg.object_path)
@@ -1870,7 +1874,7 @@ class TestDbusService(unittest.TestCase):
raise unittest.SkipTest('test not running in /dev')
for i in range(0, 5):
- pv_object_path = self._create_nested(pv_object_path)
+ pv_object_path = self._create_nested(pv_object_path, "nest_%d_" % i)
def test_pv_symlinks(self):
# Let's take one of our test PVs, pvremove it, find a symlink to it
6 months, 1 week