Blame SOURCES/sos-bz2054883-plugopt-logging-effective-opts.patch

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