summaryrefslogtreecommitdiff
path: root/daemons
diff options
context:
space:
mode:
authorTony Asleson <tasleson@redhat.com>2022-08-26 11:10:24 -0500
committerTony Asleson <tasleson@redhat.com>2022-09-16 10:49:37 -0500
commite6e874922e05e2b163b7f03b61cd4fb51e0858f6 (patch)
tree71d2ef38b9e042384a38a986d7e62a9400ad5445 /daemons
parent0296e56073667216e6b1d7397880b02df8df54c8 (diff)
downloadlvm2-e6e874922e05e2b163b7f03b61cd4fb51e0858f6.tar.gz
lvmdbusd: Handle SIGINT quietly
Change how we exit on SIGINT so that we don't output needless debug.
Diffstat (limited to 'daemons')
-rw-r--r--daemons/lvmdbusd/cmdhandler.py2
-rw-r--r--daemons/lvmdbusd/fetch.py4
-rw-r--r--daemons/lvmdbusd/lvm_shell_proxy.py.in17
-rw-r--r--daemons/lvmdbusd/main.py2
-rw-r--r--daemons/lvmdbusd/request.py3
5 files changed, 19 insertions, 9 deletions
diff --git a/daemons/lvmdbusd/cmdhandler.py b/daemons/lvmdbusd/cmdhandler.py
index 11cd0f0cd..23104e93e 100644
--- a/daemons/lvmdbusd/cmdhandler.py
+++ b/daemons/lvmdbusd/cmdhandler.py
@@ -170,7 +170,7 @@ def call_lvm(command, debug=False, line_cb=None,
return process.returncode, stdout_text, stderr_text
else:
if cfg.run.value == 0:
- raise Exception("Daemon is exiting!")
+ raise SystemExit
# We can bail out before the lvm command finished when we get a signal
# which is requesting we exit
return -errno.EINTR, "", "operation interrupted"
diff --git a/daemons/lvmdbusd/fetch.py b/daemons/lvmdbusd/fetch.py
index 5cb98853a..6cf64f148 100644
--- a/daemons/lvmdbusd/fetch.py
+++ b/daemons/lvmdbusd/fetch.py
@@ -154,6 +154,8 @@ class StateUpdate(object):
obj.deferred = False
if len(queued_requests) == 0 and wait:
+ # Note: If we don't have anything for 2 seconds we will
+ # get a queue.Empty exception raised here
queued_requests.append(obj.queue.get(True, 2))
# Ok we have one or the deferred queue has some,
@@ -192,6 +194,8 @@ class StateUpdate(object):
except queue.Empty:
pass
+ except SystemExit:
+ break
except Exception as e:
exception_count += 1
if exception_count >= 5:
diff --git a/daemons/lvmdbusd/lvm_shell_proxy.py.in b/daemons/lvmdbusd/lvm_shell_proxy.py.in
index 66c90c38a..feb93fbfa 100644
--- a/daemons/lvmdbusd/lvm_shell_proxy.py.in
+++ b/daemons/lvmdbusd/lvm_shell_proxy.py.in
@@ -109,6 +109,13 @@ class LVMShellProxy(object):
log_debug(str(ioe))
pass
+ if keep_reading and run.value == 0:
+ # We didn't complete as we are shutting down
+ # Try to clean up lvm shell process
+ log_debug("exiting lvm shell as we are shutting down")
+ self.exit_shell()
+ raise SystemExit
+
return stdout, report_json, stderr
def _write_cmd(self, cmd):
@@ -226,16 +233,10 @@ class LVMShellProxy(object):
error_msg = 'No error reason provided! (missing "log" section)'
if debug or rc != 0:
- log_error(('CMD: %s' % cmd))
- log_error(("EC = %d" % rc))
+ log_error(("CMD= %s" % cmd))
+ 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 3fcabe6b6..b485e0245 100644
--- a/daemons/lvmdbusd/main.py
+++ b/daemons/lvmdbusd/main.py
@@ -50,6 +50,8 @@ def process_request():
log_debug("Method complete: %s" % str(req.method))
except queue.Empty:
pass
+ except SystemExit:
+ break
except Exception:
st = traceback.format_exc()
utils.log_error("process_request exception: \n%s" % st)
diff --git a/daemons/lvmdbusd/request.py b/daemons/lvmdbusd/request.py
index 546b85b23..d6024d99e 100644
--- a/daemons/lvmdbusd/request.py
+++ b/daemons/lvmdbusd/request.py
@@ -71,6 +71,9 @@ class RequestEntry(object):
try:
result = self.method(*self.arguments)
self.register_result(result)
+ except SystemExit as se:
+ self.register_error(-1, str(se), se)
+ raise se
except Exception as e:
# Use the request entry to return the result as the client may
# have gotten a job by the time we hit an error