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

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