sos updates to RHEL9.0

Resolves: bz2024892 bz2024893 bz2025611

Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
This commit is contained in:
Pavel Moravec 2021-11-22 21:53:28 +01:00
parent ce0a111147
commit e5162f63d5
3 changed files with 1552 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,150 @@
From 2e8b5e2d4f30854cce93d149fc7d24b9d9cfd02c Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Fri, 19 Nov 2021 16:16:07 +0100
Subject: [PATCH 1/3] [policies] strip path from SFTP upload filename
When case_id is not supplied, we ask SFTP server to store the uploaded
file under name /var/tmp/<tarball>, which is confusing.
Let remove the path from it also in case_id not supplied.
Related to: #2764
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
sos/policies/distros/redhat.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sos/policies/distros/redhat.py b/sos/policies/distros/redhat.py
index 3476e21fb..8817fc785 100644
--- a/sos/policies/distros/redhat.py
+++ b/sos/policies/distros/redhat.py
@@ -269,10 +269,10 @@ def _get_sftp_upload_name(self):
"""The RH SFTP server will only automatically connect file uploads to
cases if the filename _starts_ with the case number
"""
+ fname = self.upload_archive_name.split('/')[-1]
if self.case_id:
- return "%s_%s" % (self.case_id,
- self.upload_archive_name.split('/')[-1])
- return self.upload_archive_name
+ return "%s_%s" % (self.case_id, fname)
+ return fname
def upload_sftp(self):
"""Override the base upload_sftp to allow for setting an on-demand
From 61023b29a656dd7afaa4a0643368b0a53f1a3779 Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Fri, 19 Nov 2021 17:31:31 +0100
Subject: [PATCH 2/3] [redhat] update SFTP API version to v2
Change API version from v1 to v2, which includes:
- change of URL
- different URI
- POST method for token generation instead of GET
Resolves: #2764
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
sos/policies/distros/redhat.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sos/policies/distros/redhat.py b/sos/policies/distros/redhat.py
index 8817fc785..e4e2b8835 100644
--- a/sos/policies/distros/redhat.py
+++ b/sos/policies/distros/redhat.py
@@ -175,7 +175,7 @@ def get_tmp_dir(self, opt_tmp_dir):
No changes will be made to system configuration.
"""
-RH_API_HOST = "https://access.redhat.com"
+RH_API_HOST = "https://api.access.redhat.com"
RH_SFTP_HOST = "sftp://sftp.access.redhat.com"
@@ -287,12 +287,12 @@ def upload_sftp(self):
" for obtaining SFTP auth token.")
_token = None
_user = None
+ url = RH_API_HOST + '/support/v2/sftp/token'
# we have a username and password, but we need to reset the password
# to be the token returned from the auth endpoint
if self.get_upload_user() and self.get_upload_password():
- url = RH_API_HOST + '/hydra/rest/v1/sftp/token'
auth = self.get_upload_https_auth()
- ret = requests.get(url, auth=auth, timeout=10)
+ ret = requests.post(url, auth=auth, timeout=10)
if ret.status_code == 200:
# credentials are valid
_user = self.get_upload_user()
@@ -302,8 +302,8 @@ def upload_sftp(self):
"credentials. Will try anonymous.")
# we either do not have a username or password/token, or both
if not _token:
- aurl = RH_API_HOST + '/hydra/rest/v1/sftp/token?isAnonymous=true'
- anon = requests.get(aurl, timeout=10)
+ adata = {"isAnonymous": True}
+ anon = requests.post(url, data=json.dumps(adata), timeout=10)
if anon.status_code == 200:
resp = json.loads(anon.text)
_user = resp['username']
From 267da2156ec61f526dd28e760ff6528408a76c3f Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Mon, 22 Nov 2021 15:22:32 +0100
Subject: [PATCH 3/3] [policies] Deal 200 return code as success
Return code 200 of POST method request must be dealt as success.
Newly required due to the SFTP API change using POST.
Related to: #2764
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
sos/policies/distros/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sos/policies/distros/__init__.py b/sos/policies/distros/__init__.py
index 0906fa779..6f257fdce 100644
--- a/sos/policies/distros/__init__.py
+++ b/sos/policies/distros/__init__.py
@@ -551,7 +551,7 @@ def upload_https(self):
r = self._upload_https_put(arc, verify)
else:
r = self._upload_https_post(arc, verify)
- if r.status_code != 201:
+ if r.status_code != 200 and r.status_code != 201:
if r.status_code == 401:
raise Exception(
"Authentication failed: invalid user credentials"
From 8da1b14246226792c160dd04e5c7c75dd4e8d44b Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Mon, 22 Nov 2021 10:44:09 +0100
Subject: [PATCH] [collect] fix moved get_upload_url under Policy class
SoSCollector does not further declare get_upload_url method
as that was moved under Policy class(es).
Resolves: #2766
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
sos/collector/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py
index 50183e873..42a7731d6 100644
--- a/sos/collector/__init__.py
+++ b/sos/collector/__init__.py
@@ -1219,7 +1219,7 @@ this utility or remote systems that it c
msg = 'No sosreports were collected, nothing to archive...'
self.exit(msg, 1)
- if self.opts.upload and self.get_upload_url():
+ if self.opts.upload and self.policy.get_upload_url():
try:
self.policy.upload_archive(arc_name)
self.ui_log.info("Uploaded archive successfully")

View File

@ -5,7 +5,7 @@
Summary: A set of tools to gather troubleshooting information from a system
Name: sos
Version: 4.2
Release: 4%{?dist}
Release: 5%{?dist}
Group: Applications/System
Source0: https://github.com/sosreport/sos/archive/%{version}/sos-%{version}.tar.gz
Source1: sos-audit-%{auditversion}.tgz
@ -37,6 +37,8 @@ Patch10: sos-bz2019697-openvswitch-offline-analysis.patch
Patch11: sos-bz2012859-plugin-timeout-unhandled-exception.patch
Patch12: sos-bz2023481-plugin-timeouts-proper-handling.patch
Patch13: sos-bz2020778-filter-namespace-per-pattern.patch
Patch14: sos-bz2024893-cleaner-hostnames-improvements.patch
Patch15: sos-bz2025611-RHTS-api-change.patch
%description
Sos is a set of tools that gathers information about system
@ -60,6 +62,8 @@ support technicians and developers.
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%build
%py3_build
@ -127,6 +131,14 @@ of the system. Currently storage and filesystem commands are audited.
%changelog
* Mon Nov 22 2021 Pavel Moravec <pmoravec@redhat.com> = 4.2-5
- [clean,hostname_parser] Source /etc/hosts for obfuscation
Resolves: bz2024893
- [clean, hostname] Fix unintentionally case sensitive
Resolves: bz2024892
- [redhat] update SFTP API version to v2
Resolves: bz2025611
* Tue Nov 16 2021 Pavel Moravec <pmoravec@redhat.com> = 4.2-4
- [report] Calculate sizes of dirs, symlinks and manifest in
Resolves: bz2011537