summaryrefslogtreecommitdiff
path: root/daemons/lvmdbusd
Commit message (Collapse)AuthorAgeFilesLines
* lvmdbus: preserve PATH envvarZdenek Kabelac2023-04-231-0/+2
|
* lvmdbusd: Add a flag to activate LVs in shared mode to Lv.ActivateVojtech Trefny2023-04-201-0/+4
|
* lvmdbusd: Correct seg. fault on s390x ELNTony Asleson2023-03-301-2/+9
| | | | | | | | syscall 186 is specific to x86 64bit. As this is different from arch to arch and between same arch different arch size we will only grab thread ID using built-in python support if it is supported. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2166931
* lvmdbusd: Correct locking for _common_logTony Asleson2023-03-301-2/+3
| | | | | | Reduce the lock time and include the flush in the lock. Reported by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
* Fix import of utils from lvmdbusd.cfgAdam Williamson2023-03-211-1/+1
| | | | Signed-off-by: Adam Williamson <awilliam@redhat.com>
* lvmdbusd: Add a new 'Shared' property to the Vg interfaceVojtech Trefny2023-03-151-0/+5
| | | | Signed-off-by: Vojtech Trefny <vtrefny@redhat.com>
* lvmdbusd: Add a retries during initial loadTony Asleson2023-03-101-2/+11
| | | | | | | | When the daemon is starting we do an initial fetch of lvm state. If we happened to get some type of failure with lvm during this time we would exit. During error injection testing this happened enough that the unit tests were unable to finish. Add retries to ensure we can get started during error injection testing.
* lvmdbusd: Handle missing key in get_keyTony Asleson2023-03-101-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | When we sort the LVs, we can stumble on a missing key, protect against this as well. Seen in error injection testing: Traceback (most recent call last): File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/fetch.py", line 198, in update_thread num_changes = load(*_load_args(queued_requests)) File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/fetch.py", line 83, in load rc = MThreadRunner(_main_thread_load, refresh, emit_signal).done() File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/utils.py", line 726, in done raise self.exception File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/utils.py", line 732, in _run self.rc = self.f(*self.args) File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/fetch.py", line 40, in _main_thread_load (lv_changes, remove) = load_lvs( File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/lv.py", line 148, in load_lvs return common( File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/loader.py", line 37, in common objects = retrieve(search_keys, cache_refresh=False) File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/lv.py", line 72, in lvs_state_retrieve lvs = sorted(cfg.db.fetch_lvs(selection), key=get_key) File "/home/tasleson/projects/lvm2/daemons/lvmdbusd/lv.py", line 35, in get_key pool = i['pool_lv'] KeyError: 'pool_lv'
* lvmdbusd: Replace assert with exceptionTony Asleson2023-03-101-1/+3
| | | | Instead of using an assert we will raise an LvmBug exception
* lvmdbusd: Add needed env. variablesTony Asleson2023-03-061-0/+2
| | | | When running lvmdb.py by itself for testing we need these.
* lvmdbusd: Move cfg.lvmdebug data initTony Asleson2023-03-062-8/+5
| | | | | Move this to the cfg file itself, so that initialization runs when it gets processed.
* lvmdbustest: Test duplicate VG renameTony Asleson2023-03-031-2/+4
|
* lvmdbusd: Remove unused importTony Asleson2023-02-271-1/+1
|
* lvmdbusd: Add lock to prevent concurrent lvm shell accessTony Asleson2023-02-271-33/+45
| | | | | | | | | | | | | | | | | There is a window of time where the following can occur. 1. An API request is in process to the lvm shell, we have written some command to the lvm shell and we are blocked on that thread waiting 2. A signal arrives to the daemon which causes us to exit. The signal handling code path goes directly to the lvm shell and writes "exit\n". This causes the lvm shell to simply exit. 3. The thread that was waiting for a response gets an EIO as the child process has exited. This bubbles up a failure. This is addressed by placing a lock in the lvm shell to prevent concurrent access to the shell. We also gather additional debug data when we get an error in the lvm shell read path. This should help if the lvm shell exits/crashes on its own.
* lvmdbusd: Disable collecting lvm debug data by defaultTony Asleson2023-02-203-5/+14
|
* lvmdbusd: Fix grammarTony Asleson2023-02-2011-24/+24
|
* lvmdbusd: Add command_log_selection to command lineTony Asleson2022-11-291-16/+17
| | | | Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2145114
* lvmdbusd: Move get_error_msg to utilsTony Asleson2022-11-292-20/+20
| | | | Moving this so we can re-use outside of lvm_shell_proxy.
* lvmdbusd: Handle PV signature copyTony Asleson2022-10-201-3/+7
| | | | | If something manually copies a PV signature to a block device we will miss it. Handle this case too.
* lvmdbusd: Always leverage udevTony Asleson2022-10-203-14/+15
| | | | | | | | | | | | | 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
* lvmdbusd: Correct env. variableTony Asleson2022-09-301-1/+1
| | | | | Make this match the unit test expectation and the form we use for other env. variables.
* lvmdbusd: Correct lvm shell signal & child process handlingTony Asleson2022-09-223-11/+35
| | | | | | | | | | 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.
* lvmdbusd: Register for SIGTERMTony Asleson2022-09-201-0/+1
| | | | Ensure we log that we are exiting on this signal too.
* lvmdbusd: Correct get_object_path_by_uuid_lvm_idTony Asleson2022-09-202-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* lvmdbusd: Remove --reportformatTony Asleson2022-09-161-2/+1
| | | | | | | | 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."
* lvmdbusd: Include lvm debug output for lvmshellTony Asleson2022-09-161-6/+5
| | | | | | 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.
* lvmdbusd: Call readlines instead of readlineTony Asleson2022-09-161-2/+4
| | | | | Better to drain everything we have now that our IO is line orientated when using a ptty.
* lvmdbusd: Raise IOError instead of ignoringTony Asleson2022-09-161-1/+2
| | | | | We end up in a bad state if we simply eat IOErrors here. Exit the lvmshell process and raise the IOError.
* lvmdbusd: Correct log_error for shell proxyTony Asleson2022-09-161-1/+1
|
* lvmdbusd: Check for KeyError in refreshTony Asleson2022-09-161-27/+33
| | | | Bubble up a LvmBug if we get a KeyError on a lvm column name.
* lvmdbusd: Use common func. for checking missing LV keysTony Asleson2022-09-164-9/+21
|
* lvmdbusd: Correct undefined varTony Asleson2022-09-161-1/+2
|
* lvmdbusd: Handle 'exit' for lvm_shell_proxyTony Asleson2022-09-161-0/+3
| | | | Useful for testing `exit_shell` when running interactively.
* lvmdbusd: Use pseudo tty to get "lvm>" prompt againTony Asleson2022-09-161-49/+63
| | | | | | | 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.
* lvmdbusd: Remove PID from log messagesTony Asleson2022-09-163-2/+25
| | | | | Previously the daemon would output PID:TID. If it's running under systemd it skips outputting PID as systemd already does this.
* lvmdbusd: Remove duplicate codeTony Asleson2022-09-161-30/+10
| | | | | The logic for _cache_lv and _writecache_lv was identical except for which underlying lvm command to run. Factor out common.
* lvmdbusd: Raise LvmBug exception for invalid JSONTony Asleson2022-09-161-4/+4
| | | | This will cause lvm debug data to get logged if it's available.
* lvmdbusd: Instruct lvm to output debug to file for fullreportTony Asleson2022-09-165-14/+87
| | | | | | | | | | | | | | | | | | | | | 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
* lvmdbusd: Re-work error handlingTony Asleson2022-09-166-100/+140
| | | | | | | | 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.
* lvmdbusd: Use common function for tracebackTony Asleson2022-09-167-29/+28
| | | | | We were using a number of different ways to achieve the same result. Use a common function to make this consistent.
* lvmdbusd: Don't output debug for fullreport exit code 5Tony Asleson2022-09-161-1/+1
| | | | This is expected with an exported vg
* lvmdbusd: refactor and correct fetch thread logicTony Asleson2022-09-161-29/+24
| | | | | Simplify the fetch thread and correct the logic used for selecting the options which are used when we batch update a state refresh.
* lvmdbusd: Re-work error handling for run_cmdTony Asleson2022-09-161-3/+10
| | | | | | 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.
* lvmdbusd: Handle SIGINT quietlyTony Asleson2022-09-165-9/+19
| | | | Change how we exit on SIGINT so that we don't output needless debug.
* lvmdbusd: Don't report recoverable errorTony Asleson2022-09-162-9/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* lvmdbusd: WS, imports, grammarTony Asleson2022-09-166-28/+22
|
* lvmdbusd: Add debug circular bufferTony Asleson2022-09-167-4/+47
| | | | | | 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.
* lvmdbusd: Set LVM_COMMAND_PROFILE=lvmdbusdTony Asleson2022-09-161-1/+3
| | | | | We need this to prevent lvm from interleaving the JSON output with errors written to stderr.
* lvmdbusd: Correct typosTony Asleson2022-09-161-1/+1
|
* lvmdbusd: fix hangs on SIGINTTony Asleson2022-09-164-19/+49
| | | | | | 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.