diff options
author | Pavel Moravec <pmoravec@redhat.com> | 2021-11-04 23:14:21 +0100 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2021-11-09 10:03:18 -0500 |
commit | 568eb2fbcf74ecad00d5c06989f55f8a6a9e3516 (patch) | |
tree | 431ce59ed6c6821290bd002fe2b0f0b76a9cec88 | |
parent | 22754fd1275c2c1597a953c02121b1fdf57dddd0 (diff) | |
download | sos-568eb2fbcf74ecad00d5c06989f55f8a6a9e3516.tar.gz |
[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>
-rw-r--r-- | sos/report/plugins/__init__.py | 15 |
1 files 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 |