Update to 4.11.2-4

Resolves: RHEL-189440

Signed-off-by: Jan Jansky <jjansky@redhat.com>
This commit is contained in:
Jan Jansky 2026-07-30 15:31:15 +02:00
parent 8f9b76ca73
commit ecf5ec8b3b
3 changed files with 173 additions and 2 deletions

View File

@ -0,0 +1,74 @@
From 6085b2580173a7a43de8b541584c82481c617aa2 Mon Sep 17 00:00:00 2001
From: asadawar <asadawar@users.noreply.github.com>
Date: Mon, 27 Jul 2026 17:50:42 +0530
Subject: [PATCH] [policies] Prefer most specific policy when multiple match
When multiple policies within the same module return True from
check(), the policy loader now selects the most specific one
(deepest in the class hierarchy) instead of whichever happens
to sort first alphabetically.
Previously, import_policy() returned classes sorted by name via
inspect.getmembers(), and load() picked the first match. This
caused RHELPolicy to always win over RedHatCoreOSPolicy inside
a toolbox container on RHCOS, because uppercase 'H' sorts before
lowercase 'e' in ASCII. Both policies return True in that context
(RHEL for the container's /etc/redhat-release, RHCOS for the
host's /host/etc/os-release), but the more specific RHCOS policy
was never reached.
This has existed since RedHatCoreOSPolicy was introduced in 2019
(commit fa06bc09c95c) but was never visible because RHCOS had no
behavioral differences from RHEL until the archive naming change
in commit 0e919b6.
The fix collects all matching policies from a module and sorts by
MRO depth (descending), so a subclass is always preferred over
its parent. This is safe because a subclass that returns True from
check() is by definition a more precise match than its parent.
Assisted-by: Claude Code <https://claude.ai/code>
Signed-off-by: asadawar <asadawar@users.noreply.github.com>
---
sos/policies/__init__.py | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index 35b3a532..b4920e82 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -29,20 +29,24 @@ def import_policy(name):
return None
-def load(cache={}, sysroot=None, init=None, probe_runtime=True,
+def load(cache=None, sysroot=None, init=None, probe_runtime=True,
remote_exec=None, remote_check=''):
+ if cache is None:
+ cache = {}
if 'policy' in cache:
return cache.get('policy')
import sos.policies.distros
helper = ImporterHelper(sos.policies.distros)
+ matches = []
for module in helper.get_modules():
- for policy in import_policy(module):
- if policy.check(remote=remote_check):
- cache['policy'] = policy(sysroot=sysroot, init=init,
- probe_runtime=probe_runtime,
- remote_exec=remote_exec)
- break
+ matches.extend([policy for policy in (import_policy(module) or [])
+ if policy.check(remote=remote_check)])
+ if matches:
+ matches.sort(key=lambda p: len(p.__mro__), reverse=True)
+ cache['policy'] = matches[0](sysroot=sysroot, init=init,
+ probe_runtime=probe_runtime,
+ remote_exec=remote_exec)
if sys.platform != 'linux':
raise Exception("SoS is not supported on this platform")
--
2.55.0

View File

@ -0,0 +1,90 @@
From d94095e55d69d5e4135df0193c9726c2789526ab Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Wed, 29 Jul 2026 10:46:25 +0200
Subject: [PATCH] [processor] Limit /sys/devices/system/cpu/cpu* subdirs
collected
For systems with >500 CPUs, collecting all such directories means
millions of files to be collected, what excessivelly slows down the
plugin until its timeout.
Limit the default number of such directories to 64, configurable via a
plugin option.
Resolves: #4399
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
sos/report/plugins/processor.py | 41 ++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/sos/report/plugins/processor.py b/sos/report/plugins/processor.py
index 9375b5a1..593bd36b 100644
--- a/sos/report/plugins/processor.py
+++ b/sos/report/plugins/processor.py
@@ -6,7 +6,9 @@
#
# See the LICENSE file in the source distribution for further information.
-from sos.report.plugins import Plugin, IndependentPlugin, SoSPredicate
+import re
+from sos.report.plugins import (Plugin, IndependentPlugin, SoSPredicate,
+ PluginOpt)
from sos.policies.distros.ubuntu import UbuntuPolicy
@@ -18,6 +20,11 @@ class Processor(Plugin, IndependentPlugin):
profiles = ('system', 'hardware', 'memory')
files = ('/proc/cpuinfo',)
packages = ('cpufreq-utils', 'cpuid')
+ option_list = [
+ PluginOpt('max_cpu_dirs', default=64, val_type=int,
+ desc='Maximum number of cpu[0-9]+ directories '
+ 'to collect from /sys/devices/system/cpu'),
+ ]
cpu_kmods = []
@@ -43,7 +50,39 @@ class Processor(Plugin, IndependentPlugin):
# copy /sys/devices/system/cpu/cpuX with separately applied sizelimit
# this is required for systems with tens/hundreds of CPUs where the
# cumulative directory size exceeds 25MB or even 100MB.
+ # Limit cpu[0-9]* directories to avoid excessive collection.
+ # All non-cpu* directories are always collected.
+ max_cpu_dirs = self.get_option('max_cpu_dirs')
+ if max_cpu_dirs < 0:
+ self._log_info(f"Invalid max_cpu_dirs={max_cpu_dirs} value "
+ f"provided, replacing by 0."
+ )
+ max_cpu_dirs = 0
cdirs = self.listdir('/sys/devices/system/cpu')
+
+ if len(cdirs) > max_cpu_dirs:
+ # separate cpu from non-cpu, then limit cpu dirs
+ cpu_pattern = re.compile(r'cpu(\d+)')
+ cpu_dirs = []
+ other_dirs = []
+
+ for cdir in cdirs:
+ if cpu_pattern.fullmatch(cdir):
+ cpu_dirs.append(cdir)
+ else:
+ other_dirs.append(cdir)
+
+ # Only limit if cpu_dirs specifically exceeds max
+ if len(cpu_dirs) > max_cpu_dirs:
+ self._log_info(
+ f"Limiting cpu directories from {len(cpu_dirs)} to "
+ f"{max_cpu_dirs} (use '-k processor.max_cpu_dirs=N' "
+ f"to change)."
+ )
+ cpu_dirs = sorted(cpu_dirs)[:max_cpu_dirs]
+
+ cdirs = other_dirs + cpu_dirs
+
self.add_copy_spec([
self.path_join('/sys/devices/system/cpu', cdir) for cdir in cdirs
])
--
2.55.0

View File

@ -5,7 +5,7 @@
Summary: A set of tools to gather troubleshooting information from a system
Name: sos
Version: 4.11.2
Release: 2%{?dist}
Release: 4%{?dist}
Group: Applications/System
Source0: https://github.com/sosreport/sos/archive/%{version}/sos-%{version}.tar.gz
Source1: sos-audit-%{auditversion}.tgz
@ -28,6 +28,8 @@ Patch3: 0003-sosreport-binary.patch
Patch4: 0004-revert-PR4092-and-PR4275.patch
Patch5: 0005-foreman-installer-Scrub-secrets-in-CLI-arg-dumps.patch
Patch6: 0006-foremanctl-valkey-PR4376.patch
Patch7: 0007-policies-Prefer-most-specific-policy-when-multiple-m.patch
Patch8: 0008-processor-Limit-sys-devices-system-cpu-cpu-subdirs-c.patch
%description
Sos is a set of tools that gathers information about system
@ -44,6 +46,8 @@ support technicians and developers.
%patch -P 4 -p1
%patch -P 5 -p1
%patch -P 6 -p1
%patch -P 7 -p1
%patch -P 8 -p1
%build
%py3_build
@ -116,7 +120,10 @@ of the system. Currently storage and filesystem commands are audited.
%license LICENSE
%changelog
* Fri Jul 17 2026 Jan Jansky <jjansky@redhat.com> - 4.11.2-2
* Wed Aug 05 2026 Jan Jansky <jjansky@redhat.com> = 4.11.2-4
- Update to 4.11.2-4
* Fri Jul 17 2026 Jan Jansky <jjansky@redhat.com> = 4.11.2-2
- Update to 4.11.2-2
* Wed Jul 15 2026 Jan Jansky <jjansky@redhat.com> = 4.11.2-1