From: Kefu Chai Date: Wed, 10 Feb 2021 07:49:03 +0000 (+0800) Subject: mgr/prometheus: add prometheus to flake8 test X-Git-Tag: v16.2.0~106^2~9 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=60e6010fa585f99b63b81ab4c6d1dedfa778db58;p=ceph.git 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) --- 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