]> sourceware.org Git - lvm2.git/log
lvm2.git
23 months agocmd: save device_id_sysfs_dir
David Teigland [Mon, 24 Oct 2022 21:15:53 +0000 (16:15 -0500)]
cmd: save device_id_sysfs_dir

read and save device_id_sysfs_dir to avoid spamming
debug output from find_config_tree_str.

23 months agolvmdbusd: Handle PV signature copy
Tony Asleson [Thu, 20 Oct 2022 15:46:51 +0000 (10:46 -0500)]
lvmdbusd: Handle PV signature copy

If something manually copies a PV signature to a block device we will
miss it.  Handle this case too.

23 months agolvmdbustest: Add test for copy signature
Tony Asleson [Thu, 20 Oct 2022 17:48:40 +0000 (12:48 -0500)]
lvmdbustest: Add test for copy signature

Add test to ensure we detect when a PV signature is copied to a block
device.

23 months agolvmdbusd: Always leverage udev
Tony Asleson [Tue, 18 Oct 2022 17:30:09 +0000 (12:30 -0500)]
lvmdbusd: Always leverage udev

Previously we utilized udev until we got a dbus notification from lvm
command line tools.  This however misses the case where something outside
of lvm clears the signatures on a block device and we fail to refresh the
state of the daemon.  Change the behavior so we always monitor udev events,
but ignore those udev events that pertain to lvm members.

Note: --udev command line option no longer does anything and simply
outputs a message that it's no longer used.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1967171

23 months agolvmdbustest: Add test for wipefs
Tony Asleson [Tue, 18 Oct 2022 17:26:14 +0000 (12:26 -0500)]
lvmdbustest: Add test for wipefs

Ensure that if an external program or user calles wipefs on a PV that we
correctly update the state of the daemon.

23 months agolvmnotify.c: Check to see if dbus daemon is running
Tony Asleson [Wed, 19 Oct 2022 17:46:45 +0000 (12:46 -0500)]
lvmnotify.c: Check to see if dbus daemon is running

The lvm dbus daemon will auto activate on dbus API calls.  To
prevent the dbus daemon starting when lvm command line tools are
being used we will check to see if the daemon is running first.
If the daemon is not running, we will not notify the daemon.

For this check to work it requires the changes done previously
with commit: 3fdf4493481ff8baae2ac5416dce6d05b69e6b28

Reviewed-by: David Teigland <teigland@redhat.com>
2 years agolvreduce: change error message about --fs options
David Teigland [Wed, 12 Oct 2022 15:05:14 +0000 (10:05 -0500)]
lvreduce: change error message about --fs options

2 years agolvmlockd: Fix sanlock lvmlock lv size calculation
corubba [Wed, 12 Oct 2022 14:19:01 +0000 (09:19 -0500)]
lvmlockd: Fix sanlock lvmlock lv size calculation

The number of extents for the sanlock lvmlock lv is calculated using
integer division, which rounds towards zero. With a physical extent size
of 129M, instead of the requested 256M the lv is only 129M (1 extent).
With any physical extent size greater than 256M the lv creation fails
because the number of extents is zero.

This is fixed by replacing the integer division with a division macro
that rounds up and thus guarantees that the size of the lv will always
be equal or greater than the requested size. Using the examples above, a
pes of 129M will result in a 258M lv (2 extents), pes of 300M in a 300M
lv (1 extent).

The re-calculation of the lv size in bytes and megabytes is only so the
debug output shows the correct values. The size in mb there is still
not byte-perfect-accurate, but good enough for a human-readable estimate;
and the exact size in bytes and extents is right next to it.

Signed-off-by: corubba <corubba@gmx.de>
2 years agotoollib: do not process just created historical LV
Peter Rajnoha [Wed, 12 Oct 2022 12:41:58 +0000 (14:41 +0200)]
toollib: do not process just created historical LV

When executing process_each_lv_in_vg, we process live LVs first and
after that, we process any historical LVs. In case we have just removed
an LV, which also means we have just made it "historical" and so it
appears as fresh item in vg->historical_lvs list, we have to skip it
when we get to processing historical LVs inside the same process_each_lv_in_vg
call.

The simplest approach here, without introducing another LV list, is to
simply mark such historical LVs as "fresh" directly in struct
historical_logical_volume when we have just removed the original LV
and created the historical LV for it. Then, we just need to check the
flag when processing historical LVs and skip it if it is "fresh".

When we read historical LVs out of metadata, they are marked as
"not fresh" and so they can be processed as usual.

This was mainly an issue in conjuction with -S|--select use:

#  lvmconfig --type diff
metadata {
record_lvs_history=1
}

(In this example, a thin pool with lvol1 thin LV and lvol2 and lvol3 snapshots.)

#  lvs -H vg -o name,pool_lv,full_ancestors,full_descendants
  LV    Pool FAncestors  FDescendants
  lvol1 pool             lvol2,lvol3
  lvol2 pool lvol1       lvol3
  lvol3 pool lvol2,lvol1
  pool

#  lvremove -S 'name=lvol2'
  Logical volume "lvol2" successfully removed.
  Historical logical volume "lvol2" successfully removed.

...here, the historical LV lvol2 should not have been removed because
we have just removed its original non-historical lvol2 and the fresh
historical lvol2 must not be included in the same processing spree.

2 years agolvreduce: require active LV when no fs option is used
David Teigland [Tue, 11 Oct 2022 16:50:47 +0000 (11:50 -0500)]
lvreduce: require active LV when no fs option is used

Without an --fs option set, make lvreduce of an inactive LV
fail and report that the LV must be active.

2 years agotests: add comments to fsadm-renamed
David Teigland [Tue, 11 Oct 2022 16:28:19 +0000 (11:28 -0500)]
tests: add comments to fsadm-renamed

to explain the what and why of the steps that are
not obvious

2 years agolvmlockd: fix warning
David Teigland [Tue, 11 Oct 2022 17:35:38 +0000 (12:35 -0500)]
lvmlockd: fix warning

2 years agotests: skip lvresize tests without mkfs.xfs
David Teigland [Mon, 10 Oct 2022 18:25:50 +0000 (13:25 -0500)]
tests: skip lvresize tests without mkfs.xfs

2 years agolvmdevices: use deviceidtype option strictly
David Teigland [Thu, 15 Sep 2022 14:45:21 +0000 (09:45 -0500)]
lvmdevices: use deviceidtype option strictly

Only use the device id type specified by --deviceidtype,
and fail if that type is not available for the device.

2 years agotests: device ids using vpd data
David Teigland [Tue, 20 Sep 2022 15:54:57 +0000 (10:54 -0500)]
tests: device ids using vpd data

2 years agodevice id: add new types using values from vpd_pg83
David Teigland [Wed, 31 Aug 2022 21:05:07 +0000 (16:05 -0500)]
device id: add new types using values from vpd_pg83

The new device_id types are: wwid_naa, wwid_eui, wwid_t10.
The new types use the specific wwid type in their name.
lvm currently gets the values for these types by reading
the device's vpd_pg83 sysfs file (this could change in the
future if better methods become available for reading the
values.)

If a device is added to the devices file using one of these
types, prior versions of lvm will not recognize the types
and will be unable to use the devices.

When adding a new device, lvm continues to first use sys_wwid
from the sysfs wwid file.  If the device has no sysfs wwid file,
lvm now attempts to use one of the new types from vpd_pg83.

If a devices file entry with type sys_wwid does not match a
given device's sysfs wwid file, the sys_wwid value will also
be compared to that device's other wwids from its vpd_pg83 file.
If the kernel changes the wwid type reported from the sysfs
wwid file, e.g. from a device's t10 id to its naa id, then lvm
should still be able to match it correctly using the vpd_pg83
data which will include both ids.

2 years agodevice id: change space handling in t10 wwid
David Teigland [Wed, 31 Aug 2022 20:59:28 +0000 (15:59 -0500)]
device id: change space handling in t10 wwid

t10 wwids are now edited in the same way that multipath does,
which is replacing a series of spaces with one _.  Previously
lvm replaced every space with one _.  Devices file entries
with the old form will be converted to the new shorter form.

2 years agodevice id wwid adjustments
David Teigland [Tue, 30 Aug 2022 20:10:52 +0000 (15:10 -0500)]
device id wwid adjustments

Move the functions handling dev wwids.

Add dev flags indicating that wwids have been read from
sysfs wwid file or sysfs vpd_pg83 file.  This can be
used to avoid rereading these.

Improve filter-mpath search for a device's wwid in
/etc/multipath/wwids, to avoid unnecessary rereading
of wwids from sysfs files.

Type 8 wwids from vpd_pg83 with naa or eui names should be
saved as those types.

2 years agolvmlockd: purge the lock resources left in previous lockspace
Lidong Zhong [Fri, 30 Sep 2022 08:34:51 +0000 (16:34 +0800)]
lvmlockd: purge the lock resources left in previous lockspace

If lvmlockd in cluster is killed accidently or any other reason, the
lock resources will become orphaned in the VG lockspace. When the
cluster manager tries to restart this daemon, the LVs will probably
become inactive because of resource schedule policy and thus the lock
resouce will be omited during the adoption process. This patch will
try to purge the lock resources left in previous lockspace, so the
following actions can work again.

2 years agolvresize: move the lockd_lv earlier
David Teigland [Fri, 30 Sep 2022 17:16:32 +0000 (12:16 -0500)]
lvresize: move the lockd_lv earlier

the lock should cover any potential activation,
not just the resizing changes

2 years agolvmdbusd: Correct env. variable
Tony Asleson [Fri, 30 Sep 2022 16:49:49 +0000 (11:49 -0500)]
lvmdbusd: Correct env. variable

Make this match the unit test expectation and the form we use for
other env. variables.

2 years agoblkid: fix BLKID_SUBLKS_FSINFO usage
David Teigland [Thu, 29 Sep 2022 20:25:32 +0000 (15:25 -0500)]
blkid: fix BLKID_SUBLKS_FSINFO usage

Use this flag for all fs info lookups, including BLOCK_SIZE,
if it is defined in blkid.h.

2 years agolvresize: give special advice to reiserfs users
David Teigland [Wed, 28 Sep 2022 16:52:40 +0000 (11:52 -0500)]
lvresize: give special advice to reiserfs users

2 years agolvresize: exclude new fs handling at build time
David Teigland [Wed, 28 Sep 2022 16:02:17 +0000 (11:02 -0500)]
lvresize: exclude new fs handling at build time

Exclude the new fs resizing capabilities at build time
(rather than run time) if the necessary libblkid features
are not available.  When excluded, all fs resizing options
are translated to resize_fsadm.  Accessing the new
features now requires rebuilding lvm if libblkid is
upgraded.

2 years agolvresize: let env var set lvresize_fs_helper_path
David Teigland [Tue, 27 Sep 2022 20:39:09 +0000 (15:39 -0500)]
lvresize: let env var set lvresize_fs_helper_path

2 years agoremove unused variables
David Teigland [Tue, 27 Sep 2022 20:40:39 +0000 (15:40 -0500)]
remove unused variables

2 years agochange messages about libblkid features
David Teigland [Tue, 27 Sep 2022 20:10:04 +0000 (15:10 -0500)]
change messages about libblkid features

remove message about missing libblkid features

change message recommending resize_fsadm when libblkid
features are not available.

2 years agolvreduce: use temporary flag when activating lv to check for fs
David Teigland [Tue, 27 Sep 2022 17:59:17 +0000 (12:59 -0500)]
lvreduce: use temporary flag when activating lv to check for fs

This flag is meant to suppress udev processing of the LV.

2 years agomake: move cmds.h
David Teigland [Tue, 27 Sep 2022 14:06:06 +0000 (09:06 -0500)]
make: move cmds.h

generate the header in the include dir so it
can be easily used from both lib and tools dirs.

2 years agolvmdbustest: Add test to stress mode changing
Tony Asleson [Thu, 22 Sep 2022 22:11:45 +0000 (17:11 -0500)]
lvmdbustest: Add test to stress mode changing

Add a test to toggle from fork & exec to lvm shell repeatedly, to stress
test it.

2 years agolvmdbustest: Re-work setUp
Tony Asleson [Thu, 22 Sep 2022 22:10:13 +0000 (17:10 -0500)]
lvmdbustest: Re-work setUp

Place the addCleanup at the end as we don't want to go through clean up
if we don't make it through setUp.  If we don't do this we can remove VGs
that we didn't create in the unit test.

2 years agolvmdbustest: Refuse to remove a VG we didn't create
Tony Asleson [Thu, 22 Sep 2022 21:18:48 +0000 (16:18 -0500)]
lvmdbustest: Refuse to remove a VG we didn't create

One of our previous commits introduced the side effect that we could
inadvertently remove a VG we didn't create, and lose data.

2 years agolvmdbustest: Make vg name suffix more unique
Tony Asleson [Thu, 22 Sep 2022 21:17:20 +0000 (16:17 -0500)]
lvmdbustest: Make vg name suffix more unique

2 years agolvmdbusd: Correct lvm shell signal & child process handling
Tony Asleson [Wed, 21 Sep 2022 15:05:36 +0000 (10:05 -0500)]
lvmdbusd: Correct lvm shell signal & child process handling

Previously when the __del__ method ran on LVMShellProxy we would blindly
call terminate().  This was a race condition as the underlying process
may/maynot be present.  When the process is still present the SIGTERM will
end up being seen by lvmdbusd too.  Re-work the code so that we
first try to wait for the child process to exit and only then if it hasn't
exited will we send it a SIGTERM.  We also ensure that when this is
executed we will briefly ignore a SIGTERM that arrives for the daemon.

2 years agocovscan: free wwid strings in lvmcache
David Teigland [Wed, 21 Sep 2022 17:15:13 +0000 (12:15 -0500)]
covscan: free wwid strings in lvmcache

2 years agomake: generate
Zdenek Kabelac [Fri, 16 Sep 2022 10:52:28 +0000 (12:52 +0200)]
make: generate

2 years agotests: validate CONFIG_HZ_1000
Zdenek Kabelac [Wed, 21 Sep 2022 12:44:05 +0000 (14:44 +0200)]
tests: validate CONFIG_HZ_1000

If we plan to use dm throttling for mirror targets - we actually
have to check whether kernel runs with CONFIG_HZ_1000 - if it does
not the whole idea of throttling is actually not working in the
testsuite as within a single 'tick' with HZ 100 way too much date
is being moved on any modern hardware - and since there is no plan
to change this in kernel - we simply avoid using throttling on such
kernel and test needs to work differently - either ignore results
or use much larger mirror sizes...

2 years agotests: discard update
Zdenek Kabelac [Fri, 16 Sep 2022 10:52:08 +0000 (12:52 +0200)]
tests: discard update

2 years agomakefiles: use single libs definition
Zdenek Kabelac [Mon, 5 Sep 2022 13:57:21 +0000 (15:57 +0200)]
makefiles: use single libs definition

2 years agotests: integrity switch to ext4
Zdenek Kabelac [Fri, 9 Sep 2022 11:33:28 +0000 (13:33 +0200)]
tests: integrity switch to ext4

Since we would need to create a lot of 300M filesystem,
switch this test suite to ext4.

2 years agolvmdbusd: Register for SIGTERM
Tony Asleson [Tue, 20 Sep 2022 19:28:57 +0000 (14:28 -0500)]
lvmdbusd: Register for SIGTERM

Ensure we log that we are exiting on this signal too.

2 years agolvmdbusd: Correct get_object_path_by_uuid_lvm_id
Tony Asleson [Tue, 20 Sep 2022 16:40:15 +0000 (11:40 -0500)]
lvmdbusd: Correct get_object_path_by_uuid_lvm_id

When checking to see if the PV is missing we incorrectly checked that the
path_create was equal to PV creation.  However, there are cases where we
are doing a lookup where the path_create == None.  In this case, we would
fail to set lvm_id == None which caused a problem as we had more than 1
PV that was missing.  When this occurred, the second lookup matched the
first missing PV that was added to the object manager.  This resulted in
the following:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/lvmdbusd/utils.py", line 667, in _run
    self.rc = self.f(*self.args)
  File "/usr/lib/python3.9/site-packages/lvmdbusd/fetch.py", line 25, in _main_thread_load
    (changes, remove) = load_pvs(
  File "/usr/lib/python3.9/site-packages/lvmdbusd/pv.py", line 46, in load_pvs
    return common(
  File "/usr/lib/python3.9/site-packages/lvmdbusd/loader.py", line 55, in common
    del existing_paths[dbus_object.dbus_object_path()]

Because we expect to find the object in existing_paths if we found it in
the lookup.

resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2085078

2 years agomake: Fix build in chroot dev-mcsontos-lib-tools-dependency
Marian Csontos [Tue, 20 Sep 2022 13:56:13 +0000 (15:56 +0200)]
make: Fix build in chroot

When building in a buildroot, must create libexec directory explicitly.

2 years agospec: Workaround for failing build
Marian Csontos [Tue, 20 Sep 2022 13:12:44 +0000 (15:12 +0200)]
spec: Workaround for failing build

Commit 18722dfdf4d3e6f172d0b2af8bbdc4a154ea1dc0 introduced a dependency
on file from tools/ into lib/.

TODO: revert this once the issue is resolved.

2 years agolvmdbusd: Remove --reportformat
Tony Asleson [Wed, 14 Sep 2022 18:11:47 +0000 (13:11 -0500)]
lvmdbusd: Remove --reportformat

Latest upstream build of lvm results in the following error when
trying to use lvmshell.

"Argument --reportformat cannot be used in interactive mode.,
Error during parsing of command line."

2 years agolvmdbustest: Add wrapper for injecting errors
Tony Asleson [Fri, 9 Sep 2022 21:05:11 +0000 (16:05 -0500)]
lvmdbustest: Add wrapper for injecting errors

Useful for forcing lvmdbusd down error paths.

2 years agolvmdbusd: Include lvm debug output for lvmshell
Tony Asleson [Fri, 9 Sep 2022 15:03:35 +0000 (10:03 -0500)]
lvmdbusd: Include lvm debug output for lvmshell

Move the option to add the debug file into lvm_full_report_json so that
we collect the debug data when we fork & exec lvm and when we use lvm
shell.

2 years agolvmdbusd: Call readlines instead of readline
Tony Asleson [Thu, 8 Sep 2022 20:42:26 +0000 (15:42 -0500)]
lvmdbusd: Call readlines instead of readline

Better to drain everything we have now that our IO is line orientated
when using a ptty.

2 years agolvmdbusd: Raise IOError instead of ignoring
Tony Asleson [Thu, 8 Sep 2022 20:41:20 +0000 (15:41 -0500)]
lvmdbusd: Raise IOError instead of ignoring

We end up in a bad state if we simply eat IOErrors here.  Exit the lvmshell
process and raise the IOError.

2 years agolvmdbusd: Correct log_error for shell proxy
Tony Asleson [Thu, 8 Sep 2022 20:40:03 +0000 (15:40 -0500)]
lvmdbusd: Correct log_error for shell proxy

2 years agolvmdbusd: Check for KeyError in refresh
Tony Asleson [Thu, 8 Sep 2022 20:39:30 +0000 (15:39 -0500)]
lvmdbusd: Check for KeyError in refresh

Bubble up a LvmBug if we get a KeyError on a lvm column name.

2 years agolvmdbusd: Use common func. for checking missing LV keys
Tony Asleson [Thu, 8 Sep 2022 20:38:31 +0000 (15:38 -0500)]
lvmdbusd: Use common func. for checking missing LV keys

2 years agolvmdbusd: Correct undefined var
Tony Asleson [Thu, 8 Sep 2022 20:37:34 +0000 (15:37 -0500)]
lvmdbusd: Correct undefined var

2 years agolvmdbustest: Check for self.pvs
Tony Asleson [Thu, 8 Sep 2022 20:29:55 +0000 (15:29 -0500)]
lvmdbustest: Check for self.pvs

If we don't make it through setUp, self.pvs will not exist.

2 years agolvmdbustest: Move signals to last
Tony Asleson [Thu, 8 Sep 2022 20:28:52 +0000 (15:28 -0500)]
lvmdbustest: Move signals to last

When we do the signal testing we default back to fork & exec.  Put these
on the end to maximize our lvm shell testing until we fix this proper.

2 years agolvmdbusd: Handle 'exit' for lvm_shell_proxy
Tony Asleson [Tue, 6 Sep 2022 21:24:20 +0000 (16:24 -0500)]
lvmdbusd: Handle 'exit' for lvm_shell_proxy

Useful for testing `exit_shell` when running interactively.

2 years agolvmdbusd: Use pseudo tty to get "lvm>" prompt again
Tony Asleson [Tue, 6 Sep 2022 21:23:06 +0000 (16:23 -0500)]
lvmdbusd: Use pseudo tty to get "lvm>" prompt again

When lvm is compiled with editline, if the file descriptors don't look like
a tty, then no "lvm> " prompt is done.  Having lvm output the shell prompt
when consuming JSON on a report file descriptor is very useful in
determining if lvm command is complete.

2 years agolvmdbusd: Remove PID from log messages
Tony Asleson [Thu, 1 Sep 2022 02:25:36 +0000 (21:25 -0500)]
lvmdbusd: Remove PID from log messages

Previously the daemon would output PID:TID.  If it's running under systemd
it skips outputting PID as systemd already does this.

2 years agolvmdbustest: Utilize addCleanup in unit test
Tony Asleson [Wed, 31 Aug 2022 23:03:16 +0000 (18:03 -0500)]
lvmdbustest: Utilize addCleanup in unit test

Register the clean up with addCleanup so we ensure clean_up gets run
regardless of what happens in setUp.

2 years agolvmdbusd: Remove duplicate code
Tony Asleson [Wed, 31 Aug 2022 20:42:48 +0000 (15:42 -0500)]
lvmdbusd: Remove duplicate code

The logic for _cache_lv and _writecache_lv was identical except for which
underlying lvm command to run.  Factor out common.

2 years agolvmdbusd: Raise LvmBug exception for invalid JSON
Tony Asleson [Wed, 31 Aug 2022 20:08:09 +0000 (15:08 -0500)]
lvmdbusd: Raise LvmBug exception for invalid JSON

This will cause lvm debug data to get logged if it's available.

2 years agolvmdbusd: Instruct lvm to output debug to file for fullreport
Tony Asleson [Wed, 31 Aug 2022 20:04:59 +0000 (15:04 -0500)]
lvmdbusd: Instruct lvm to output debug to file for fullreport

Historically we have seen a few different errors which occur when we call
fullreport.  Failing exit code and JSON which is missing one or more keys.
Instruct lvm to dump the debug to a file during fullreport calls when we
fork & exec lvm. If we encounter an error, ouput the debug data.
The reason this isn't being done when lvmshell is used is because we
don't have an easy way to test the error paths.

This change is complicated by the following:

1. We don't know if fullreport was good until we evaluate all the JSON.
   This is done a bit after we have called into lvm and returned.
2. We don't want to orphan the debug file used by lvm if the daemon is
   killed. Thus we try to minimize the window where the debug file hasn't
   already been unlinked.  A RFE to pass an open FD to lvm for this
   purpose is outstanding.

The temp. file is:
-rw------. 1 root root /tmp/lvmdbusd.lvm.debug.XXXXXXXX.log

2 years agolvmdbusd: Re-work error handling
Tony Asleson [Wed, 31 Aug 2022 16:20:49 +0000 (11:20 -0500)]
lvmdbusd: Re-work error handling

Introduce an exception which is used for known existing issues with lvm.
This is used to distinguish between errors between lvm itself and lvmdbusd.
In the case of lvm bugs, when we simply retry the operation we will log
very little.  Otherwise, we will dump a full traceback for investigation
when we do the retry.

2 years agolvmdbusd: Use common function for traceback
Tony Asleson [Wed, 31 Aug 2022 16:18:55 +0000 (11:18 -0500)]
lvmdbusd: Use common function for traceback

We were using a number of different ways to achieve the same result.  Use
a common function to make this consistent.

2 years agolvmdbusd: Don't output debug for fullreport exit code 5
Tony Asleson [Wed, 31 Aug 2022 16:05:36 +0000 (11:05 -0500)]
lvmdbusd: Don't output debug for fullreport exit code 5

This is expected with an exported vg

2 years agolvmdbustest: Skip test_nesting if scan_lvs is not enabled
Tony Asleson [Tue, 30 Aug 2022 17:47:14 +0000 (12:47 -0500)]
lvmdbustest: Skip test_nesting if scan_lvs is not enabled

2 years agolvmdbusd: refactor and correct fetch thread logic
Tony Asleson [Mon, 29 Aug 2022 21:18:06 +0000 (16:18 -0500)]
lvmdbusd: refactor and correct fetch thread logic

Simplify the fetch thread and correct the logic used for selecting the
options which are used when we batch update a state refresh.

2 years agolvmdbusd: Re-work error handling for run_cmd
Tony Asleson [Fri, 26 Aug 2022 18:01:05 +0000 (13:01 -0500)]
lvmdbusd: Re-work error handling for run_cmd

Instead of lumping all the exceptions, break them out to handle the dbus
exceptions separately, to reduce the amount of debug information that ends
up in the journal that has questionable value.

2 years agolvmdbusd: Handle SIGINT quietly
Tony Asleson [Fri, 26 Aug 2022 16:10:24 +0000 (11:10 -0500)]
lvmdbusd: Handle SIGINT quietly

Change how we exit on SIGINT so that we don't output needless debug.

2 years agolvmdbusd: Don't report recoverable error
Tony Asleson [Thu, 25 Aug 2022 14:33:50 +0000 (09:33 -0500)]
lvmdbusd: Don't report recoverable error

Lvm occasionally fails to return all the request JSON keys in the output of
"fullreport".  This happens very rarely.  When it does the daemon was reporting
the resulting informational exception:

MThreadRunner: exception
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/lvmdbusd/utils.py", line 667, in _run
    self.rc = self.f(*self.args)
  File "/usr/lib/python3.9/site-packages/lvmdbusd/fetch.py", line 40, in _main_thread_load
    (lv_changes, remove) = load_lvs(
  File "/usr/lib/python3.9/site-packages/lvmdbusd/lv.py", line 143, in load_lvs
    return common(
  File "/usr/lib/python3.9/site-packages/lvmdbusd/loader.py", line 37, in common
    objects = retrieve(search_keys, cache_refresh=False)
  File "/usr/lib/python3.9/site-packages/lvmdbusd/lv.py", line 95, in lvs_state_retrieve
    l['vdo_operating_mode'],
KeyError: 'vdo_operating_mode'

The daemon retries the operation, which usually works and the daemon continues.
However, simply reporting this informational stack trace is causing CI and other
automated tests to fail as they expect no tracebacks in the log output.

Remove the reporting of this code path unless it persists and causes the daemon
to give up and exit.

Ref: https://bugzilla.redhat.com/show_bug.cgi?id=2120267

2 years agolvmdbusd: WS, imports, grammar
Tony Asleson [Thu, 25 Aug 2022 13:33:50 +0000 (08:33 -0500)]
lvmdbusd: WS, imports, grammar

2 years agolvmdbusd: Add debug circular buffer
Tony Asleson [Wed, 17 Aug 2022 22:24:08 +0000 (17:24 -0500)]
lvmdbusd: Add debug circular buffer

When the daemon isn't started with --debug we will keep a circular
buffer of the past N number of debug messages which we will output
when we encounter an issue.

2 years agolvmdbustest: Skip test_singleton_daemon running systemd svc.
Tony Asleson [Wed, 24 Aug 2022 20:41:03 +0000 (15:41 -0500)]
lvmdbustest: Skip test_singleton_daemon running systemd svc.

2 years agolvmdbusd: Set LVM_COMMAND_PROFILE=lvmdbusd
Tony Asleson [Wed, 24 Aug 2022 20:37:56 +0000 (15:37 -0500)]
lvmdbusd: Set LVM_COMMAND_PROFILE=lvmdbusd

We need this to prevent lvm from interleaving the JSON output with errors
written to stderr.

2 years agolvmdbustest: Add systemctl daemon start
Tony Asleson [Tue, 23 Aug 2022 15:54:22 +0000 (10:54 -0500)]
lvmdbustest: Add systemctl daemon start

2 years agolvmdbustest: Add test for ensuring only 1 instance of daemon
Tony Asleson [Tue, 23 Aug 2022 15:31:31 +0000 (10:31 -0500)]
lvmdbustest: Add test for ensuring only 1 instance of daemon

2 years agolvmdbustest: Add test_sigint test
Tony Asleson [Tue, 23 Aug 2022 15:30:53 +0000 (10:30 -0500)]
lvmdbustest: Add test_sigint test

Get the daemon busy and send it SIGINT to ensure the daemon exits.

2 years agolvmdbustest: Add optional option to _create_num_lvs
Tony Asleson [Tue, 23 Aug 2022 15:29:26 +0000 (10:29 -0500)]
lvmdbustest: Add optional option to _create_num_lvs

This allows us to create the LVs async., thus queuing them up in daemon.

2 years agolvmdbustest: Factor out tearDown implementation for re-use
Tony Asleson [Tue, 23 Aug 2022 15:28:27 +0000 (10:28 -0500)]
lvmdbustest: Factor out tearDown implementation for re-use

2 years agolvmdbustest: Add DaemonInfo class
Tony Asleson [Tue, 23 Aug 2022 15:27:30 +0000 (10:27 -0500)]
lvmdbustest: Add DaemonInfo class

This class handles identifying daemon, sending signals to it, and starting
it back up again.

2 years agolvmdbusd: Correct typos
Tony Asleson [Tue, 23 Aug 2022 15:24:37 +0000 (10:24 -0500)]
lvmdbusd: Correct typos

2 years agolvmdbusd: fix hangs on SIGINT
Tony Asleson [Wed, 17 Aug 2022 22:21:19 +0000 (17:21 -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.

2 years agolvmdbustest: Add test removing incomplete job
Tony Asleson [Wed, 17 Aug 2022 17:14:02 +0000 (12:14 -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.

2 years agolvmdbustest: Add test for external event
Tony Asleson [Wed, 17 Aug 2022 17:12:17 +0000 (12:12 -0500)]
lvmdbustest: Add test for external event

Ensure that when we trigger an external event that we don't incorrectly
handle multiple --config options.

2 years agolvmdbustest: Add test for passing log file in options
Tony Asleson [Wed, 17 Aug 2022 17:11:07 +0000 (12:11 -0500)]
lvmdbustest: Add test for passing log file in options

2 years agolvmdbusd: Remove unused locking functionality
Tony Asleson [Wed, 17 Aug 2022 17:09:30 +0000 (12:09 -0500)]
lvmdbusd: Remove unused locking functionality

I don't think we have ever utilized this, remove.

2 years agolvmdbusd: Make sure to set cfg.got_external_event
Tony Asleson [Wed, 17 Aug 2022 17:08:16 +0000 (12:08 -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.

2 years agolvmdbusd: Correct typos
Tony Asleson [Wed, 17 Aug 2022 17:06:17 +0000 (12:06 -0500)]
lvmdbusd: Correct typos

2 years agolvmdbusd: Handle no lastlog
Tony Asleson [Wed, 17 Aug 2022 17:05:06 +0000 (12:05 -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.

2 years agolvmdbustest: nesting improvements
Tony Asleson [Wed, 10 Aug 2022 18:59:11 +0000 (13:59 -0500)]
lvmdbustest: nesting improvements

2 years agolvmdbusd: Remove exclusionary language
Tony Asleson [Tue, 9 Aug 2022 22:55:27 +0000 (17:55 -0500)]
lvmdbusd: Remove exclusionary language

2 years agolvmdbusd: Remove unneeded command line args
Tony Asleson [Tue, 9 Aug 2022 22:45:04 +0000 (17:45 -0500)]
lvmdbusd: Remove unneeded command line args

2 years agolvmdbusd: Add SIGUSR2 to dump flight recorder
Tony Asleson [Tue, 9 Aug 2022 22:44:10 +0000 (17:44 -0500)]
lvmdbusd: Add SIGUSR2 to dump flight recorder

2 years agolvmdbusd: Re-work flight recorder data
Tony Asleson [Tue, 9 Aug 2022 22:43:00 +0000 (17:43 -0500)]
lvmdbusd: Re-work flight recorder data

Introduce a new lock for the flight recorder, so that we can dump it when
a command is block waiting for lvm to complete.  Also in all paths we will
addthe metadata to the flight recorder before it's done, so we will have
it when a command hangs and we dump the flight recorder. Add the missing
bits after the command has finished.

Cleaned up the output too.

2 years agolvmdbustest: Remove force exception in _wait_for_job
Tony Asleson [Tue, 9 Aug 2022 22:36:54 +0000 (17:36 -0500)]
lvmdbustest: Remove force exception in _wait_for_job

We put this in to test one of the paths in the damon, but unfortunately
if we hit the race condition where the job actually is done we will try
to call j.Wait(1) after the remove.  This fails with:

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod:
Method "Wait" with signature "i" on interface "com.redhat.lvmdbus1.Job"
doesn't exist

Which is caused by the dbus object no longer existing.  We could handle
this, but the issue is we no longer have the ability to get the result to
return, they have been lost.

A better solution would be to write a specific unit test to force this code
path and handle all the possible outcomes.

2 years agolvmdbusd: Add lockfile
Tony Asleson [Tue, 9 Aug 2022 01:48:10 +0000 (20:48 -0500)]
lvmdbusd: Add lockfile

The daemon cannot handle multiple copies of itself running at the
same time, ensure this cannot happen.

2 years agolvmdbusd: Move arg. setup/checking to function
Tony Asleson [Tue, 9 Aug 2022 01:44:32 +0000 (20:44 -0500)]
lvmdbusd: Move arg. setup/checking to function

2 years agolvmdbusd: Remove addl. checks on --nojson
Tony Asleson [Mon, 8 Aug 2022 21:08:23 +0000 (16:08 -0500)]
lvmdbusd: Remove addl. checks on --nojson

We check earlier that if you specify --nojson we will exit.

2 years agolvmdbustest: Include major number 259
Tony Asleson [Mon, 8 Aug 2022 15:03:52 +0000 (10:03 -0500)]
lvmdbustest: Include major number 259

When you have > 16 partitions for a block device the major number
changes, include them for testing.

2 years agolvmdbustest: Use updated pyudev syntax
Tony Asleson [Mon, 8 Aug 2022 15:02:37 +0000 (10:02 -0500)]
lvmdbustest: Use updated pyudev syntax

Previous syntax has been deprecated.

This page took 0.076921 seconds and 5 git commands to generate.