sos/sos-bz2020778-filter-namespace-per-pattern.patch
Pavel Moravec b6c480a921 sos updates to RHEL 9.0 GA
Resolves: bz2011537 bz2012859 bz2020778 bz2023481

Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
2021-11-15 22:35:41 +01:00

55 lines
1.8 KiB
Diff

From 568eb2fbcf74ecad00d5c06989f55f8a6a9e3516 Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Thu, 4 Nov 2021 23:14:21 +0100
Subject: [PATCH] [report] fix filter_namespace per pattern
Curently, -k networking.namespace_pattern=.. is broken as the R.E. test
forgets to add the namespace in case of positive match.
Also ensure both plugopts namespace_pattern and namespaces work
together.
Resolves: #2748
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
sos/report/plugins/__init__.py | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/sos/report/plugins/__init__.py b/sos/report/plugins/__init__.py
index 3e717993..a0d4e95d 100644
--- a/sos/report/plugins/__init__.py
+++ b/sos/report/plugins/__init__.py
@@ -2953,21 +2953,20 @@ class Plugin():
)
for ns in ns_list:
# if ns_pattern defined, skip namespaces not matching the pattern
- if ns_pattern:
- if not bool(re.match(pattern, ns)):
- continue
+ if ns_pattern and not bool(re.match(pattern, ns)):
+ continue
+ out_ns.append(ns)
- # if ns_max is defined at all, limit returned list to that number
+ # if ns_max is defined at all, break the loop when the limit is
+ # reached
# this allows the use of both '0' and `None` to mean unlimited
- elif ns_max:
- out_ns.append(ns)
+ if ns_max:
if len(out_ns) == ns_max:
self._log_warn("Limiting namespace iteration "
"to first %s namespaces found"
% ns_max)
break
- else:
- out_ns.append(ns)
+
return out_ns
--
2.31.1