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