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

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