Blame SOURCES/sos-bz2018033-plugin-timeouts-proper-handling.patch

003633
From 3fea9a564c4112d04f6324df0d8b212e78feb5b3 Mon Sep 17 00:00:00 2001
003633
From: Jake Hunsaker <jhunsake@redhat.com>
003633
Date: Wed, 3 Nov 2021 11:02:54 -0400
003633
Subject: [PATCH] [Plugin] Ensure specific plugin timeouts are only set for
003633
 that plugin
003633
003633
It was discovered that setting a specific plugin timeout via the `-k
003633
$plugin.timeout` option could influence the timeout setting for other
003633
plugins that are not also having their timeout explicitly set. Fix this
003633
by moving the default plugin opts into `Plugin.__init__()` so that each
003633
plugin is ensured a private copy of these default plugin options.
003633
003633
Additionally, add more timeout data to plugin manifest entries to allow
003633
for better tracking of this setting.
003633
003633
Adds a test case for this scenario.
003633
003633
Closes: #2744
003633
003633
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
003633
---
003633
 sos/report/__init__.py                   |  2 +-
003633
 sos/report/plugins/__init__.py           | 28 +++++++++++++------
003633
 tests/vendor_tests/redhat/rhbz2018033.py | 35 ++++++++++++++++++++++++
003633
 3 files changed, 55 insertions(+), 10 deletions(-)
003633
 create mode 100644 tests/vendor_tests/redhat/rhbz2018033.py
003633
003633
diff --git a/sos/report/__init__.py b/sos/report/__init__.py
003633
index ef86b28d..c95e6300 100644
003633
--- a/sos/report/__init__.py
003633
+++ b/sos/report/__init__.py
003633
@@ -766,7 +766,7 @@ class SoSReport(SoSComponent):
003633
         if self.all_options:
003633
             self.ui_log.info(_("The following options are available for ALL "
003633
                                "plugins:"))
003633
-            for opt in self.all_options[0][0]._default_plug_opts:
003633
+            for opt in self.all_options[0][0].get_default_plugin_opts():
003633
                 val = opt[3]
003633
                 if val == -1:
003633
                     val = TIMEOUT_DEFAULT
003633
diff --git a/sos/report/plugins/__init__.py b/sos/report/plugins/__init__.py
003633
index 49f1af27..3e717993 100644
003633
--- a/sos/report/plugins/__init__.py
003633
+++ b/sos/report/plugins/__init__.py
003633
@@ -474,12 +474,6 @@ class Plugin(object):
003633
     # Default predicates
003633
     predicate = None
003633
     cmd_predicate = None
003633
-    _default_plug_opts = [
003633
-        ('timeout', 'Timeout in seconds for plugin to finish', 'fast', -1),
003633
-        ('cmd-timeout', 'Timeout in seconds for a command', 'fast', -1),
003633
-        ('postproc', 'Enable post-processing collected plugin data', 'fast',
003633
-         True)
003633
-    ]
003633
 
003633
     def __init__(self, commons):
003633
 
003633
@@ -506,7 +500,7 @@ class Plugin(object):
003633
             else logging.getLogger('sos')
003633
 
003633
         # add the default plugin opts
003633
-        self.option_list.extend(self._default_plug_opts)
003633
+        self.option_list.extend(self.get_default_plugin_opts())
003633
 
003633
         # get the option list into a dictionary
003633
         for opt in self.option_list:
003633
@@ -591,6 +583,14 @@ class Plugin():
003633
         # Initialise the default --dry-run predicate
003633
         self.set_predicate(SoSPredicate(self))
003633
 
003633
+    def get_default_plugin_opts(self):
003633
+        return [
003633
+            ('timeout', 'Timeout in seconds for plugin to finish', 'fast', -1),
003633
+            ('cmd-timeout', 'Timeout in seconds for a command', 'fast', -1),
003633
+            ('postproc', 'Enable post-processing collected plugin data', 'fast',
003633
+             True)
003633
+        ]
003633
+
003633
     def set_plugin_manifest(self, manifest):
003633
         """Pass in a manifest object to the plugin to write to
003633
 
003633
@@ -547,7 +541,9 @@ class Plugin(object):
003633
         self.manifest.add_field('setup_start', '')
003633
         self.manifest.add_field('setup_end', '')
003633
         self.manifest.add_field('setup_time', '')
003633
+        self.manifest.add_field('timeout', self.timeout)
003633
         self.manifest.add_field('timeout_hit', False)
003633
+        self.manifest.add_field('command_timeout', self.cmdtimeout)
003633
         self.manifest.add_list('commands', [])
003633
         self.manifest.add_list('files', [])
003633