diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2021-08-30 15:09:07 -0400 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2021-09-08 09:40:35 -0400 |
commit | 5824cd5d3bddf39e0382d568419e2453abc93d8a (patch) | |
tree | c76ce3287cd3a524c8010dcd10861a69f4421c53 | |
parent | 7d025933c2cdc7bf07a7b6b9c0d8b2637ade372b (diff) | |
download | sos-5824cd5d3bddf39e0382d568419e2453abc93d8a.tar.gz |
[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 <jhunsake@redhat.com>
-rw-r--r-- | sos/options.py | 2 | ||||
-rw-r--r-- | 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() |