sos updates to RHEL9.0

Resolves: bz2037350

Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
This commit is contained in:
Pavel Moravec 2022-01-10 16:22:48 +01:00
parent da2634f52d
commit eca9c2e982
2 changed files with 104 additions and 6 deletions

View File

@ -372,14 +372,13 @@ index 4b1ee109..f79bd5ff 100644
UnsupportedHostException)
@@ -60,35 +60,23 @@ class SosNode():
'presets': [],
@@ -61,34 +61,25 @@ class SosNode():
'sos_cmd': commons['sos_cmd']
}
- self.sos_bin = 'sosreport'
self.sos_bin = 'sosreport'
- filt = ['localhost', '127.0.0.1']
- self.soslog = logging.getLogger('sos')
- self.ui_log = logging.getLogger('sos_ui')
self.soslog = logging.getLogger('sos')
self.ui_log = logging.getLogger('sos_ui')
- self.control_path = ("%s/.sos-collector-%s"
- % (self.tmpdir, self.address))
- self.ssh_cmd = self._create_ssh_command()
@ -5530,3 +5529,98 @@ index a25e794e1..ffd63bc63 100644
self.exit(msg, 1)
if self.opts.upload and self.policy.get_upload_url():
From 2c3a647817dfbac36be3768acf6026e91d1a6e8f Mon Sep 17 00:00:00 2001
From: Jake Hunsaker <jhunsake@redhat.com>
Date: Tue, 21 Dec 2021 14:20:19 -0500
Subject: [PATCH] [options] Allow spaces in --keywords values in sos.conf
The `--keywords` option supports spaces to allow for obfuscated phrases,
not just words. This however breaks if a phrase is added to the config
file *before* a run with the phrase in the cmdline option, due to the
safeguards we have for all other values that do not support spaces.
Add a check in our flow for updating options from the config file to not
replace illegal spaces if we're checking the `keywords` option, for
which spaces are legal.
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
---
sos/options.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sos/options.py b/sos/options.py
index 7bea3ffc1..4846a5096 100644
--- a/sos/options.py
+++ b/sos/options.py
@@ -200,7 +200,10 @@ def _update_from_section(section, config):
odict[rename_opts[key]] = odict.pop(key)
# set the values according to the config file
for key, val in odict.items():
- if isinstance(val, str):
+ # most option values do not tolerate spaces, special
+ # exception however for --keywords which we do want to
+ # support phrases, and thus spaces, for
+ if isinstance(val, str) and key != 'keywords':
val = val.replace(' ', '')
if key not in self.arg_defaults:
# read an option that is not loaded by the current
From f912fc9e31b406a24b7a9c012e12cda920632051 Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Mon, 10 Jan 2022 14:13:42 +0100
Subject: [PATCH] [collect] Deal None sos_version properly
In case collector cluster hits an error during init, sos_version
is None what LooseVersion can't compare properly and raises exception
'LooseVersion' object has no attribute 'version'
Related: #2822
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
sos/collector/sosnode.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sos/collector/sosnode.py b/sos/collector/sosnode.py
index 925f27909..7bbe0cd1f 100644
--- a/sos/collector/sosnode.py
+++ b/sos/collector/sosnode.py
@@ -382,7 +382,8 @@ def check_sos_version(self, ver):
given ver. This means that if the installed version is greater than
ver, this will still return True
"""
- return LooseVersion(self.sos_info['version']) >= ver
+ return self.sos_info['version'] is not None and \
+ LooseVersion(self.sos_info['version']) >= ver
def is_installed(self, pkg):
"""Checks if a given package is installed on the node"""
From 0c67e8ebaeef17dac3b5b9e42a59b4e673e4403b Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Mon, 10 Jan 2022 14:17:13 +0100
Subject: [PATCH] [collector] Cleanup cluster only if defined
In case cluster init fails, self.cluster = None and its cleanup
must be skipped.
Resolves: #2822
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
sos/collector/__init__.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py
index ffd63bc63..3e22bca3e 100644
--- a/sos/collector/__init__.py
+++ b/sos/collector/__init__.py
@@ -443,7 +443,8 @@ def add_parser_options(cls, parser):
def exit(self, msg, error=1):
"""Used to safely terminate if sos-collector encounters an error"""
- self.cluster.cleanup()
+ if self.cluster:
+ self.cluster.cleanup()
self.log_error(msg)
try:
self.close_all_connections()

View File

@ -5,7 +5,7 @@
Summary: A set of tools to gather troubleshooting information from a system
Name: sos
Version: 4.2
Release: 9%{?dist}
Release: 10%{?dist}
Group: Applications/System
Source0: https://github.com/sosreport/sos/archive/%{version}/sos-%{version}.tar.gz
Source1: sos-audit-%{auditversion}.tgz
@ -137,6 +137,10 @@ of the system. Currently storage and filesystem commands are audited.
%changelog
* Mon Jan 10 2022 Pavel Moravec <pmoravec@redhat.com> = 4.2-10
- [collector] Cleanup cluster only if defined
Resolves: bz2037350
* Fri Jan 07 2022 Pavel Moravec <pmoravec@redhat.com> = 4.2-9
- add oc transport, backport various PRs for OCP
Resolves: bz2037350