From: Kefu Chai Date: Wed, 10 Feb 2021 07:49:03 +0000 (+0800) Subject: mgr/prometheus: add prometheus to flake8 test X-Git-Tag: v17.1.0~2944^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5dd9db970994530002df3da6be075974bfef2767;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 --- diff --git a/src/pybind/mgr/prometheus/__init__.py b/src/pybind/mgr/prometheus/__init__.py index d39184947b44..af8d6616083e 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 587dbd3ba252..5400dbbf7e7c 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -201,7 +201,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) @@ -922,9 +922,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'] @@ -1047,8 +1047,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 diff --git a/src/pybind/mgr/tox.ini b/src/pybind/mgr/tox.ini index 8be4bd90eccb..36c9ef9eec64 100644 --- a/src/pybind/mgr/tox.ini +++ b/src/pybind/mgr/tox.ini @@ -121,6 +121,7 @@ modules = devicehealth hello orchestrator + prometheus commands = flake8 --config=tox.ini {posargs} \ {posargs:{[testenv:flake8]modules}}