Blame SOURCES/sos-bz1923938-sos-log-effective-options.patch

ba407d
From 00d12ad3cf24dcc6c73e9bcf63db1d3f17e58bb1 Mon Sep 17 00:00:00 2001
ba407d
From: Jake Hunsaker <jhunsake@redhat.com>
ba407d
Date: Thu, 1 Jul 2021 10:50:54 -0400
ba407d
Subject: [PATCH] [sosnode] Properly format skip-commands and skip-files on
ba407d
 nodes
ba407d
ba407d
Fixes an issue where options provided for `skip-commands` and
ba407d
`skip-files` were not properly formatted, thus causing an exception
ba407d
during the finalization of the node's sos command.
ba407d
ba407d
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
ba407d
---
ba407d
 sos/collector/sosnode.py | 5 +++--
ba407d
 1 file changed, 3 insertions(+), 2 deletions(-)
ba407d
ba407d
diff --git a/sos/collector/sosnode.py b/sos/collector/sosnode.py
ba407d
index 6597d236..426edcba 100644
ba407d
--- a/sos/collector/sosnode.py
ba407d
+++ b/sos/collector/sosnode.py
ba407d
@@ -734,11 +734,12 @@ class SosNode():
ba407d
         if self.check_sos_version('4.1'):
ba407d
             if self.opts.skip_commands:
ba407d
                 sos_opts.append(
ba407d
-                    '--skip-commands=%s' % (quote(self.opts.skip_commands))
ba407d
+                    '--skip-commands=%s' % (
ba407d
+                        quote(','.join(self.opts.skip_commands)))
ba407d
                 )
ba407d
             if self.opts.skip_files:
ba407d
                 sos_opts.append(
ba407d
-                    '--skip-files=%s' % (quote(self.opts.skip_files))
ba407d
+                    '--skip-files=%s' % (quote(','.join(self.opts.skip_files)))
ba407d
                 )
ba407d
 
ba407d
         if self.check_sos_version('4.2'):
ba407d
-- 
ba407d
2.31.1
ba407d
ba407d
From de7edce3f92ed50abcb28dd0dbcbeb104dc7c679 Mon Sep 17 00:00:00 2001
ba407d
From: Pavel Moravec <pmoravec@redhat.com>
ba407d
Date: Fri, 2 Jul 2021 09:52:11 +0200
ba407d
Subject: [PATCH] [collector] fix a typo in --plugin-option
ba407d
ba407d
Sos report uses --plugin-option or --plugopts.
ba407d
ba407d
Relevant: #2606
ba407d
ba407d
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
ba407d
---
ba407d
 sos/collector/__init__.py | 2 +-
ba407d
 1 file changed, 1 insertion(+), 1 deletion(-)
ba407d
ba407d
diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py
ba407d
index 6d96d692..f072287e 100644
ba407d
--- a/sos/collector/__init__.py
ba407d
+++ b/sos/collector/__init__.py
ba407d
@@ -272,7 +272,7 @@ class SoSCollector(SoSComponent):
ba407d
                              help="chroot executed commands to SYSROOT")
ba407d
         sos_grp.add_argument('-e', '--enable-plugins', action="extend",
ba407d
                              help='Enable specific plugins for sosreport')
ba407d
-        sos_grp.add_argument('-k', '--plugin-options', action="extend",
ba407d
+        sos_grp.add_argument('-k', '--plugin-option', action="extend",
ba407d
                              help='Plugin option as plugname.option=value')
ba407d
         sos_grp.add_argument('--log-size', default=0, type=int,
ba407d
                              help='Limit the size of individual logs (in MiB)')
ba407d
-- 
ba407d
2.31.1
ba407d
ba407d
From 24a79ae8df8f29276f6139c68d4ba9b05114f951 Mon Sep 17 00:00:00 2001
ba407d
From: Pavel Moravec <pmoravec@redhat.com>
ba407d
Date: Fri, 2 Jul 2021 09:53:47 +0200
ba407d
Subject: [PATCH] [options] allow variant option names in config file
ba407d
ba407d
While cmdline allows --plugin-option as well as --plugopts,
ba407d
it stores the value under `plugopts` key. Therefore parsing
ba407d
config file ignores --plugin-option.
ba407d
ba407d
Similarly for --name/--label and --profile/--profiles.
ba407d
ba407d
When processing config file, we must unify those potentially duplicit
ba407d
keys.
ba407d
ba407d
Resolves: #2606
ba407d
ba407d
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
ba407d
---
ba407d
 sos/options.py | 9 +++++++++
ba407d
 1 file changed, 9 insertions(+)
ba407d
ba407d
diff --git a/sos/options.py b/sos/options.py
ba407d
index 1eda55d6..a014a022 100644
ba407d
--- a/sos/options.py
ba407d
+++ b/sos/options.py
ba407d
@@ -186,9 +186,18 @@ class SoSOptions():
ba407d
                 if 'verbose' in odict.keys():
ba407d
                     odict['verbosity'] = int(odict.pop('verbose'))
ba407d
                 # convert options names
ba407d
+                # unify some of them if multiple variants of the
ba407d
+                # cmdoption exist
ba407d
+                rename_opts = {
ba407d
+                    'name': 'label',
ba407d
+                    'plugin_option': 'plugopts',
ba407d
+                    'profile': 'profiles'
ba407d
+                }
ba407d
                 for key in list(odict):
ba407d
                     if '-' in key:
ba407d
                         odict[key.replace('-', '_')] = odict.pop(key)
ba407d
+                    if key in rename_opts:
ba407d
+                        odict[rename_opts[key]] = odict.pop(key)
ba407d
                 # set the values according to the config file
ba407d
                 for key, val in odict.items():
ba407d
                     if isinstance(val, str):
ba407d
-- 
ba407d
2.31.1
ba407d
ba407d
From c7d3644c0c64e9e5439806250592a55c8e2de26f Mon Sep 17 00:00:00 2001
ba407d
From: Pavel Moravec <pmoravec@redhat.com>
ba407d
Date: Thu, 1 Jul 2021 08:11:15 +0200
ba407d
Subject: [PATCH] [report,collect] unify --map-file arguments
ba407d
ba407d
Unify --map[-file] argument among report/collect/clean.
ba407d
ba407d
Resolves: #2602
ba407d
ba407d
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
ba407d
---
ba407d
 sos/cleaner/__init__.py   | 2 +-
ba407d
 sos/collector/__init__.py | 2 +-
ba407d
 sos/report/__init__.py    | 2 +-
ba407d
 3 files changed, 3 insertions(+), 3 deletions(-)
ba407d
ba407d
diff --git a/sos/cleaner/__init__.py b/sos/cleaner/__init__.py
ba407d
index 7414b55e0..4c9837826 100644
ba407d
--- a/sos/cleaner/__init__.py
ba407d
+++ b/sos/cleaner/__init__.py
ba407d
@@ -192,7 +192,7 @@ def add_parser_options(cls, parser):
ba407d
                                      'file for obfuscation'))
ba407d
         clean_grp.add_argument('--no-update', dest='no_update', default=False,
ba407d
                                action='store_true',
ba407d
-                               help='Do not update the --map file with new '
ba407d
+                               help='Do not update the --map-file with new '
ba407d
                                     'mappings from this run')
ba407d
         clean_grp.add_argument('--keep-binary-files', default=False,
ba407d
                                action='store_true',
ba407d
diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py
ba407d
index 7b8cfcf72..6d96d6923 100644
ba407d
--- a/sos/collector/__init__.py
ba407d
+++ b/sos/collector/__init__.py
ba407d
@@ -427,7 +427,7 @@ def add_parser_options(cls, parser):
ba407d
         cleaner_grp.add_argument('--no-update', action='store_true',
ba407d
                                  default=False, dest='no_update',
ba407d
                                  help='Do not update the default cleaner map')
ba407d
-        cleaner_grp.add_argument('--map', dest='map_file',
ba407d
+        cleaner_grp.add_argument('--map-file', dest='map_file',
ba407d
                                  default='/etc/sos/cleaner/default_mapping',
ba407d
                                  help=('Provide a previously generated mapping'
ba407d
                                        ' file for obfuscation'))
ba407d
diff --git a/sos/report/__init__.py b/sos/report/__init__.py
ba407d
index 7ad2d24a4..411c4eb03 100644
ba407d
--- a/sos/report/__init__.py
ba407d
+++ b/sos/report/__init__.py
ba407d
@@ -341,7 +341,7 @@ def add_parser_options(cls, parser):
ba407d
         cleaner_grp.add_argument('--no-update', action='store_true',
ba407d
                                  default=False, dest='no_update',
ba407d
                                  help='Do not update the default cleaner map')
ba407d
-        cleaner_grp.add_argument('--map', dest='map_file',
ba407d
+        cleaner_grp.add_argument('--map-file', dest='map_file',
ba407d
                                  default='/etc/sos/cleaner/default_mapping',
ba407d
                                  help=('Provide a previously generated mapping'
ba407d
                                        ' file for obfuscation'))
ba407d
From fd75745e7a5a6c5def8e6d23190227872b9912c3 Mon Sep 17 00:00:00 2001
ba407d
From: Jake Hunsaker <jhunsake@redhat.com>
ba407d
Date: Wed, 11 Aug 2021 10:48:41 -0400
ba407d
Subject: [PATCH] [sosnode] Fix passing of plugin options when using
ba407d
 `--only-plugins`
ba407d
ba407d
Fixes the handling of plugin options passed by `sos collect` to each
ba407d
node by first aligning the SoSOption name to those of `report`
ba407d
(`plugopts`), and second re-arranges the handling of plugin options and
ba407d
preset options passed by the user when also using `--only-plugins` so
ba407d
that the former are preserved and passed only with the `--only-plugins`
ba407d
option value.
ba407d
ba407d
Resolves: #2641
ba407d
ba407d
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
ba407d
---
ba407d
 sos/collector/__init__.py |  5 +++--
ba407d
 sos/collector/sosnode.py  | 34 +++++++++++++++++-----------------
ba407d
 2 files changed, 20 insertions(+), 19 deletions(-)
ba407d
ba407d
diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py
ba407d
index 57ef074e..70b7a69e 100644
ba407d
--- a/sos/collector/__init__.py
ba407d
+++ b/sos/collector/__init__.py
ba407d
@@ -84,7 +84,7 @@ class SoSCollector(SoSComponent):
ba407d
         'only_plugins': [],
ba407d
         'password': False,
ba407d
         'password_per_node': False,
ba407d
-        'plugin_options': [],
ba407d
+        'plugopts': [],
ba407d
         'plugin_timeout': None,
ba407d
         'cmd_timeout': None,
ba407d
         'preset': '',
ba407d
@@ -273,7 +273,8 @@ class SoSCollector(SoSComponent):
ba407d
                              help="chroot executed commands to SYSROOT")
ba407d
         sos_grp.add_argument('-e', '--enable-plugins', action="extend",
ba407d
                              help='Enable specific plugins for sosreport')
ba407d
-        sos_grp.add_argument('-k', '--plugin-option', action="extend",
ba407d
+        sos_grp.add_argument('-k', '--plugin-option', '--plugopts',
ba407d
+                             action="extend", dest='plugopts',
ba407d
                              help='Plugin option as plugname.option=value')
ba407d
         sos_grp.add_argument('--log-size', default=0, type=int,
ba407d
                              help='Limit the size of individual logs (in MiB)')
ba407d
diff --git a/sos/collector/sosnode.py b/sos/collector/sosnode.py
ba407d
index 426edcba..5d05c297 100644
ba407d
--- a/sos/collector/sosnode.py
ba407d
+++ b/sos/collector/sosnode.py
ba407d
@@ -667,10 +667,10 @@ class SosNode():
ba407d
 
ba407d
         if self.cluster.sos_plugin_options:
ba407d
             for opt in self.cluster.sos_plugin_options:
ba407d
-                if not any(opt in o for o in self.plugin_options):
ba407d
+                if not any(opt in o for o in self.plugopts):
ba407d
                     option = '%s=%s' % (opt,
ba407d
                                         self.cluster.sos_plugin_options[opt])
ba407d
-                    self.plugin_options.append(option)
ba407d
+                    self.plugopts.append(option)
ba407d
 
ba407d
         # set master-only options
ba407d
         if self.cluster.check_node_is_master(self):
ba407d
@@ -688,7 +688,7 @@ class SosNode():
ba407d
         self.only_plugins = list(self.opts.only_plugins)
ba407d
         self.skip_plugins = list(self.opts.skip_plugins)
ba407d
         self.enable_plugins = list(self.opts.enable_plugins)
ba407d
-        self.plugin_options = list(self.opts.plugin_options)
ba407d
+        self.plugopts = list(self.opts.plugopts)
ba407d
         self.preset = list(self.opts.preset)
ba407d
 
ba407d
     def finalize_sos_cmd(self):
ba407d
@@ -754,6 +754,20 @@ class SosNode():
ba407d
             os.path.join(self.host.sos_bin_path, self.sos_bin)
ba407d
         )
ba407d
 
ba407d
+        if self.plugopts:
ba407d
+            opts = [o for o in self.plugopts
ba407d
+                    if self._plugin_exists(o.split('.')[0])
ba407d
+                    and self._plugin_option_exists(o.split('=')[0])]
ba407d
+            if opts:
ba407d
+                sos_opts.append('-k %s' % quote(','.join(o for o in opts)))
ba407d
+
ba407d
+        if self.preset:
ba407d
+            if self._preset_exists(self.preset):
ba407d
+                sos_opts.append('--preset=%s' % quote(self.preset))
ba407d
+            else:
ba407d
+                self.log_debug('Requested to enable preset %s but preset does '
ba407d
+                               'not exist on node' % self.preset)
ba407d
+
ba407d
         if self.only_plugins:
ba407d
             plugs = [o for o in self.only_plugins if self._plugin_exists(o)]
ba407d
             if len(plugs) != len(self.only_plugins):
ba407d
@@ -792,20 +806,6 @@ class SosNode():
ba407d
             if enable:
ba407d
                 sos_opts.append('--enable-plugins=%s' % quote(enable))
ba407d
 
ba407d
-        if self.plugin_options:
ba407d
-            opts = [o for o in self.plugin_options
ba407d
-                    if self._plugin_exists(o.split('.')[0])
ba407d
-                    and self._plugin_option_exists(o.split('=')[0])]
ba407d
-            if opts:
ba407d
-                sos_opts.append('-k %s' % quote(','.join(o for o in opts)))
ba407d
-
ba407d
-        if self.preset:
ba407d
-            if self._preset_exists(self.preset):
ba407d
-                sos_opts.append('--preset=%s' % quote(self.preset))
ba407d
-            else:
ba407d
-                self.log_debug('Requested to enable preset %s but preset does '
ba407d
-                               'not exist on node' % self.preset)
ba407d
-
ba407d
         self.sos_cmd = "%s %s" % (sos_cmd, ' '.join(sos_opts))
ba407d
         self.log_info('Final sos command set to %s' % self.sos_cmd)
ba407d
         self.manifest.add_field('final_sos_command', self.sos_cmd)
ba407d
-- 
ba407d
2.31.1
ba407d