From: Avan Thakkar Date: Fri, 7 Oct 2022 20:10:57 +0000 (+0530) Subject: mgr/prometheus: avoid duplicates and deleted entries for rbd_stats_pool X-Git-Tag: v18.1.0~997^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=06077827fe8344ca56d5a397f352bc4171affced;p=ceph.git mgr/prometheus: avoid duplicates and deleted entries for rbd_stats_pool Fixes: https://tracker.ceph.com/issues/57797 Signed-off-by: Avan Thakkar Avoid duplicate entries (pool[/namespace]) for rbd_stats_pools config and also avoid deleted pools. --- diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index afcf49820e5a..984006be16e2 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -1282,7 +1282,10 @@ class Module(MgrModule): # stats are collected for every namespace in the pool. The wildcard # '*' can be used to indicate all pools or namespaces pools_string = cast(str, self.get_localized_module_option('rbd_stats_pools')) - pool_keys = [] + pool_keys = set() + osd_map = self.get('osd_map') + rbd_pools = [pool['pool_name'] for pool in osd_map['pools'] + if 'rbd' in pool.get('application_metadata', {})] for x in re.split(r'[\s,]+', pools_string): if not x: continue @@ -1295,13 +1298,11 @@ class Module(MgrModule): if pool_name == "*": # collect for all pools - osd_map = self.get('osd_map') - for pool in osd_map['pools']: - if 'rbd' not in pool.get('application_metadata', {}): - continue - pool_keys.append((pool['pool_name'], namespace_name)) + for pool in rbd_pools: + pool_keys.add((pool, namespace_name)) else: - pool_keys.append((pool_name, namespace_name)) + if pool_name in rbd_pools: + pool_keys.add((pool_name, namespace_name)) # avoids adding deleted pool pools = {} # type: Dict[str, Set[str]] for pool_key in pool_keys: