Blame SOURCES/sos-bz2020778-filter-namespace-per-pattern.patch

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