1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

lvmdbusd: Disable collecting lvm debug data by default

This commit is contained in:
Tony Asleson 2023-02-16 16:07:32 -06:00
parent 5561281f0a
commit e18d60b336
3 changed files with 14 additions and 5 deletions

View File

@ -626,7 +626,10 @@ def lvm_full_report_json():
# We are running the fullreport command, we will ask lvm to output the debug # We are running the fullreport command, we will ask lvm to output the debug
# data, so we can have the required information for lvm to debug the fullreport failures. # data, so we can have the required information for lvm to debug the fullreport failures.
# Note: this is disabled by default and can be enabled with env. var.
# LVM_DBUSD_COLLECT_LVM_DEBUG=True
fn = cfg.lvmdebug.setup() fn = cfg.lvmdebug.setup()
if fn is not None:
add_config_option(cmd, "--config", "log {level=7 file=%s syslog=0}" % fn) add_config_option(cmd, "--config", "log {level=7 file=%s syslog=0}" % fn)
rc, out, err = call(cmd) rc, out, err = call(cmd)

View File

@ -148,6 +148,7 @@ def running_under_systemd():
def main(): def main():
start = time.time() start = time.time()
use_session = os.getenv('LVM_DBUSD_USE_SESSION', False) use_session = os.getenv('LVM_DBUSD_USE_SESSION', False)
collect_lvm_debug = os.getenv('LVM_DBUSD_COLLECT_LVM_DEBUG', False)
# Ensure that we get consistent output for parsing stdout/stderr and that we # Ensure that we get consistent output for parsing stdout/stderr and that we
# are using the lvmdbusd profile. # are using the lvmdbusd profile.
@ -156,7 +157,7 @@ def main():
# Save off the debug data needed for lvm team to debug issues # Save off the debug data needed for lvm team to debug issues
# only used for 'fullreport' at this time. # only used for 'fullreport' at this time.
cfg.lvmdebug = utils.LvmDebugData() cfg.lvmdebug = utils.LvmDebugData(collect_lvm_debug)
# Indicator if we are running under systemd # Indicator if we are running under systemd
cfg.systemd = running_under_systemd() cfg.systemd = running_under_systemd()

View File

@ -819,9 +819,12 @@ class LvmBug(RuntimeError):
class LvmDebugData: class LvmDebugData:
def __init__(self): def __init__(self, do_collection):
self.fd = -1 self.fd = -1
self.fn = None self.fn = None
self.collect = do_collection
if self.collect:
log_msg("Collecting lvm debug data!")
def _remove_file(self): def _remove_file(self):
if self.fn is not None: if self.fn is not None:
@ -835,8 +838,10 @@ class LvmDebugData:
def setup(self): def setup(self):
# Create a secure filename # Create a secure filename
if self.collect:
self.fd, self.fn = tempfile.mkstemp(suffix=".log", prefix="lvmdbusd.lvm.debug.") self.fd, self.fn = tempfile.mkstemp(suffix=".log", prefix="lvmdbusd.lvm.debug.")
return self.fn return self.fn
return None
def lvm_complete(self): def lvm_complete(self):
# Remove the file ASAP, so we decrease our odds of leaving it # Remove the file ASAP, so we decrease our odds of leaving it