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