From 5824cd5d3bddf39e0382d568419e2453abc93d8a Mon Sep 17 00:00:00 2001 From: Jake Hunsaker Date: Mon, 30 Aug 2021 15:09:07 -0400 Subject: [PATCH] [options] Fix logging on plugopts in effective sos command First, provide a special-case handling for plugin options specified in sos.conf in `SoSOptions.to_args().has_value()` that allows for plugin options to be included in the "effective options now" log message. Second, move the logging of said message (and thus the merging of preset options, if used), to being _prior_ to the loading of plugin options. Combined, plugin options specified in sos.conf will now be logged properly and this logging will occur before we set (and log the setting of) those options. Resolves: #2663 Signed-off-by: Jake Hunsaker --- sos/options.py | 2 ++ sos/report/__init__.py | 30 ++++++++++++++++-------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/sos/options.py b/sos/options.py index a014a022..7bea3ffc 100644 --- a/sos/options.py +++ b/sos/options.py @@ -281,6 +281,8 @@ class SoSOptions(): null_values = ("False", "None", "[]", '""', "''", "0") if not value or value in null_values: return False + if name == 'plugopts' and value: + return True if name in self.arg_defaults: if str(value) == str(self.arg_defaults[name]): return False diff --git a/sos/report/__init__.py b/sos/report/__init__.py index b0159e5b..82484f1d 100644 --- a/sos/report/__init__.py +++ b/sos/report/__init__.py @@ -925,20 +925,6 @@ class SoSReport(SoSComponent): self._exit(1) def setup(self): - # Log command line options - msg = "[%s:%s] executing 'sos %s'" - self.soslog.info(msg % (__name__, "setup", " ".join(self.cmdline))) - - # Log active preset defaults - preset_args = self.preset.opts.to_args() - msg = ("[%s:%s] using '%s' preset defaults (%s)" % - (__name__, "setup", self.preset.name, " ".join(preset_args))) - self.soslog.info(msg) - - # Log effective options after applying preset defaults - self.soslog.info("[%s:%s] effective options now: %s" % - (__name__, "setup", " ".join(self.opts.to_args()))) - self.ui_log.info(_(" Setting up plugins ...")) for plugname, plug in self.loaded_plugins: try: @@ -1386,11 +1372,27 @@ class SoSReport(SoSComponent): self.report_md.add_list('disabled_plugins', self.opts.skip_plugins) self.report_md.add_section('plugins') + def _merge_preset_options(self): + # Log command line options + msg = "[%s:%s] executing 'sos %s'" + self.soslog.info(msg % (__name__, "setup", " ".join(self.cmdline))) + + # Log active preset defaults + preset_args = self.preset.opts.to_args() + msg = ("[%s:%s] using '%s' preset defaults (%s)" % + (__name__, "setup", self.preset.name, " ".join(preset_args))) + self.soslog.info(msg) + + # Log effective options after applying preset defaults + self.soslog.info("[%s:%s] effective options now: %s" % + (__name__, "setup", " ".join(self.opts.to_args()))) + def execute(self): try: self.policy.set_commons(self.get_commons()) self.load_plugins() self._set_all_options() + self._merge_preset_options() self._set_tunables() self._check_for_unknown_plugins() self._set_plugin_options() -- 2.34.1