From 60e6010fa585f99b63b81ab4c6d1dedfa778db58 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 10 Feb 2021 15:49:03 +0800 Subject: [PATCH] mgr/prometheus: add prometheus to flake8 test for the explanation why we should add a line break before a binary operator. see https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator Signed-off-by: Kefu Chai (cherry picked from commit 5dd9db970994530002df3da6be075974bfef2767) --- src/pybind/mgr/prometheus/__init__.py | 1 + src/pybind/mgr/prometheus/module.py | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/prometheus/__init__.py b/src/pybind/mgr/prometheus/__init__.py index d39184947b44a..af8d6616083e4 100644 --- a/src/pybind/mgr/prometheus/__init__.py +++ b/src/pybind/mgr/prometheus/__init__.py @@ -1 +1,2 @@ +# flake8: noqa from .module import Module, StandbyModule diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index 6a38ed36ed9c1..a0f2a5024e397 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -230,7 +230,7 @@ class MetricCollectionThread(threading.Thread): try: data = self.mod.collect() - except: + except Exception: # Log any issues encountered during the data collection and continue self.mod.log.exception("failed to collect metrics:") self.event.wait(self.mod.scrape_interval) @@ -951,9 +951,9 @@ class Module(MgrModule): else: namespace_regex = '^(.*)$' - if 'query' in self.rbd_stats and \ - (pool_id_regex != self.rbd_stats['query']['key_descriptor'][0]['regex'] or - namespace_regex != self.rbd_stats['query']['key_descriptor'][1]['regex']): + if ('query' in self.rbd_stats + and (pool_id_regex != self.rbd_stats['query']['key_descriptor'][0]['regex'] + or namespace_regex != self.rbd_stats['query']['key_descriptor'][1]['regex'])): self.remove_osd_perf_query(self.rbd_stats['query_id']) del self.rbd_stats['query_id'] del self.rbd_stats['query'] @@ -1076,8 +1076,8 @@ class Module(MgrModule): if nspace_name not in nspace_names: del pool['images'][nspace_name] for nspace_name in nspace_names: - if (nspace_name and - not rbd.namespace_exists(ioctx, nspace_name)): + if nspace_name and\ + not rbd.namespace_exists(ioctx, nspace_name): self.log.debug('unknown namespace %s for pool %s' % (nspace_name, pool_name)) continue -- 2.39.5