Update to 4.8.0 in RHEL 10

Resolves: RHEL-58946

Signed-off-by: Jan Jansky <jjansky@redhat.com>
This commit is contained in:
Jan Jansky 2024-09-19 14:33:12 +02:00
parent 8c81ac18ef
commit 547094b03d
6 changed files with 123 additions and 82 deletions

1
.gitignore vendored
View File

@ -27,3 +27,4 @@ sos-2.2.tar.gz
/sos-4.7.0.tar.gz
/sos-4.7.1.tar.gz
/sos-4.7.2.tar.gz
/sos-4.8.0.tar.gz

View File

@ -0,0 +1,40 @@
From c3b8bbcf7969999375d85c588c09d90d99ea41f3 Mon Sep 17 00:00:00 2001
From: Jose Castillo <jcastillo@redhat.com>
Date: Mon, 19 Aug 2024 11:37:08 +0100
Subject: [PATCH] [redhat] Fix return of function check_file_too_big()
Fix the return of the size checks for Red Hat uploads
to customer portal. Without this fix, uploads were failing
silently.
Signed-off-by: Jose Castillo <jcastillo@redhat.com>
---
sos/policies/distros/redhat.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/sos/policies/distros/redhat.py b/sos/policies/distros/redhat.py
index fb22c313..5b794fde 100644
--- a/sos/policies/distros/redhat.py
+++ b/sos/policies/distros/redhat.py
@@ -441,8 +441,7 @@ support representative.
f"{convert_bytes(self._max_size_request)} "
" via sos http upload. \n")
)
- return RH_SFTP_HOST
- return RH_API_HOST
+ self.upload_url = RH_SFTP_HOST
def upload_archive(self, archive):
"""Override the base upload_archive to provide for automatic failover
@@ -450,7 +449,7 @@ support representative.
"""
try:
if self.get_upload_url().startswith(RH_API_HOST):
- self.upload_url = self.check_file_too_big(archive)
+ self.check_file_too_big(archive)
uploaded = super().upload_archive(archive)
except Exception as e:
uploaded = False
--
2.46.0

View File

@ -1,77 +0,0 @@
From 11879fbb1adc33d8abc0cb70dc63e7e88c39fc3f Mon Sep 17 00:00:00 2001
From: Jose Castillo <jcastillo@redhat.com>
Date: Wed, 21 Feb 2024 12:24:37 +0000
Subject: [PATCH] [redhat|policy] Check for archive size before upload
The Red Hat Customer Portal has a max limit for
single http requests of 1Gb. From sos side, we never checked this
and so customers had to wait for the whole upload to be attempted
before receiving an error from the portal.
This patch attempts to stop the upload before it starts, informing
customers of such limit, and switching to secure FTP where there's
no limit.
Related: RHEL-22732
Signed-off-by: Jose Castillo <jcastillo@redhat.com>
---
sos/policies/distros/redhat.py | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/sos/policies/distros/redhat.py b/sos/policies/distros/redhat.py
index edea151e2..2fb0df3fa 100644
--- a/sos/policies/distros/redhat.py
+++ b/sos/policies/distros/redhat.py
@@ -22,7 +22,7 @@
from sos.policies.package_managers.rpm import RpmPackageManager
from sos.policies.package_managers.flatpak import FlatpakPackageManager
from sos.policies.package_managers import MultiPackageManager
-from sos.utilities import bold
+from sos.utilities import bold, convert_bytes
from sos import _sos as _
try:
@@ -232,6 +232,8 @@ class RHELPolicy(RedHatPolicy):
_upload_url = RH_SFTP_HOST
_upload_method = 'post'
_device_token = None
+ # Max size for an http single request is 1Gb
+ _max_size_request = 1073741824
def __init__(self, sysroot=None, init=None, probe_runtime=True,
remote_exec=None):
@@ -429,15 +429,30 @@ support representative.
return super().upload_sftp(user=_user, password=_token)
raise Exception("Could not retrieve valid or anonymous credentials")
+ def check_file_too_big(self, archive):
+ size = os.path.getsize(archive)
+ # Lets check if the size is bigger than the limit.
+ # There's really no need to transform the size to Gb,
+ # so we don't need to call any size converter implemented
+ # in tools.py
+ if (size >= self._max_size_request):
+ self.ui_log.warning(
+ _("Size of archive is bigger than Red Hat Customer Portal "
+ "limit for uploads of "
+ f"{convert_bytes(self._max_size_request)} "
+ " via sos http upload. \n")
+ )
+ return RH_SFTP_HOST
+ else:
+ return RH_API_HOST
+
def upload_archive(self, archive):
"""Override the base upload_archive to provide for automatic failover
from RHCP failures to the public RH dropbox
"""
try:
- if self.upload_url and self.upload_url.startswith(RH_API_HOST) and\
- (not self.get_upload_user() or
- not self.get_upload_password()):
- self.upload_url = RH_SFTP_HOST
+ if self.get_upload_url().startswith(RH_API_HOST):
+ self.upload_url = self.check_file_too_big(archive)
uploaded = super().upload_archive(archive)
except Exception as e:
uploaded = False

View File

@ -0,0 +1,71 @@
From 3886534b707211c69e1f0ee8592ae9f9125227f2 Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Mon, 26 Aug 2024 18:59:36 +0200
Subject: [PATCH] [report] Revert changed formatting of plugin+presets lists
During conversion to f-strings in #3606, some changes in UI output
happen. That makes some output less readable and could break some
automated tests anticipating given preset or plugin output strings.
This commit reverts back tto the original output, using f-strings.
Resolves: #3762
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
sos/report/__init__.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/sos/report/__init__.py b/sos/report/__init__.py
index 15974817..24294069 100644
--- a/sos/report/__init__.py
+++ b/sos/report/__init__.py
@@ -1029,7 +1029,7 @@ class SoSReport(SoSComponent):
self.ui_log.info(_("The following plugins are currently enabled:"))
self.ui_log.info("")
for (plugname, plug) in self.loaded_plugins:
- self.ui_log.info(f"{plugname:<20} {plug.get_description()}")
+ self.ui_log.info(f" {plugname:<20} {plug.get_description()}")
else:
self.ui_log.info(_("No plugin enabled."))
self.ui_log.info("")
@@ -1039,7 +1039,7 @@ class SoSReport(SoSComponent):
"disabled:"))
self.ui_log.info("")
for (plugname, plugclass, reason) in self.skipped_plugins:
- self.ui_log.info(f"{plugname:<20} {reason:<14} "
+ self.ui_log.info(f" {plugname:<20} {reason:<14} "
f"{plugclass.get_description()}")
self.ui_log.info("")
@@ -1060,7 +1060,7 @@ class SoSReport(SoSComponent):
val = TIMEOUT_DEFAULT
if opt.name == 'postproc':
val = not self.opts.no_postproc
- self.ui_log.info(f"{opt.name:<25} {val:<15} {opt.desc}")
+ self.ui_log.info(f" {opt.name:<25} {val:<15} {opt.desc}")
self.ui_log.info("")
self.ui_log.info(_("The following plugin options are available:"))
@@ -1126,14 +1126,14 @@ class SoSReport(SoSComponent):
if not preset:
continue
preset = self.policy.find_preset(preset)
- self.ui_log.info(f"name: {preset.name:>14}")
- self.ui_log.info(f"description: {preset.desc:>14}")
+ self.ui_log.info(f"{'name:':>14} {preset.name}")
+ self.ui_log.info(f"{'description:':>14} {preset.desc}")
if preset.note:
- self.ui_log.info(f"note: {preset.note:>14}")
+ self.ui_log.info(f"{'note:':>14} {preset.note}")
if self.opts.verbosity > 0:
args = preset.opts.to_args()
- options_str = f"{'options:':>14}"
+ options_str = f"{'options:':>14} "
lines = _format_list(options_str, args, indent=True, sep=' ')
for line in lines:
self.ui_log.info(line)
--
2.46.0

View File

@ -4,8 +4,8 @@
Summary: A set of tools to gather troubleshooting information from a system
Name: sos
Version: 4.7.2
Release: 2%{?dist}
Version: 4.8.0
Release: 1%{?dist}
Group: Applications/System
Source0: https://github.com/sosreport/sos/archive/%{version}/sos-%{version}.tar.gz
Source1: sos-audit-%{auditversion}.tgz
@ -22,7 +22,8 @@ Recommends: python3-pexpect
Recommends: python3-pyyaml
Conflicts: vdsm < 4.40
Obsoletes: sos-collector <= 1.9
Patch0: sos-RHEL-22732-reverted.patch
Patch0: sos-Revert-changed-formatting.patch
Patch1: sos-RHEL-22732-Fix-check_file_too_big.patch
%description
Sos is a set of tools that gathers information about system
@ -33,7 +34,8 @@ support technicians and developers.
%prep
%setup -qn %{name}-%{version}
%setup -T -D -a1 -q
%patch0 -p1 -R
%patch -P 0 -p1
%patch -P 1 -p1
%build
%py3_build
@ -106,6 +108,10 @@ of the system. Currently storage and filesystem commands are audited.
%changelog
* Thu Sep 19 2024 Jan Jansky <jjansky@redhat.com> = 4.8.0-1
- Update to 4.8.0 in RHEL 10
Resolves: RHEL-58946
* Wed Aug 21 2024 Pavel Moravec <pmoravec@redhat.com> = 4.7.2-2
- Reverting RHEL-22732 patch due to regressions
Resolves: RHEL-50589

View File

@ -1,2 +1,2 @@
SHA512 (sos-4.7.2.tar.gz) = 00124fcd1b14a16213ddd53da9686c4efcb773321e5e6e4a2c883bbe71e8ea200055134404942140a55bd94a3aeec272c5bc296f73b5bf16c7194955442e40e6
SHA512 (sos-4.8.0.tar.gz) = d0874794d015e07cbd57ddf7f6092c8f61b8fb866abc34073c1c865353acdb1df37290aa99431e41f6c863fe6b04c16488c6ee748aba55ec81d90efd8543ad92
SHA512 (sos-audit-0.3.tgz) = 32597baf6350804d08179a0dbe48470a93df148e83d2e49bb3288f6bcc2d151bb1433761913bfbccd912c14de92435939fef5bcd7e091dfe33a345d61ea842ea