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