From: xie xingguo Date: Mon, 16 Dec 2019 05:54:50 +0000 (+0800) Subject: mgr/balancer: avoid pulling pg_dump twice X-Git-Tag: v15.1.0~466^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1b4b061ed686d3546d2d2fc40627403e25b45a87;p=ceph.git mgr/balancer: avoid pulling pg_dump twice For large cluster with thousands of osds/pgs, it may take seconds even mitutes to refresh the relevant stats. Since we already have pulling them down at initialization, make a direct use of them whenever possible. Signed-off-by: xie xingguo --- diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py index 9ea28735e7c5..041938a7471b 100644 --- a/src/pybind/mgr/balancer/module.py +++ b/src/pybind/mgr/balancer/module.py @@ -954,7 +954,7 @@ class Module(MgrModule): inc = plan.inc total_did = 0 left = max_optimizations - osdmap_dump = self.get_osdmap().dump() + osdmap_dump = ms.osdmap_dump pools_with_pg_merge = [p['pool_name'] for p in osdmap_dump.get('pools', []) if p['pg_num'] > p['pg_num_target']] crush_rule_by_pool_name = dict((p['pool_name'], p['crush_rule']) for p in osdmap_dump.get('pools', [])) @@ -984,7 +984,7 @@ class Module(MgrModule): # since scrubbing activities have significant impacts on performance pool_ids = list(p['pool'] for p in pool_dump if p['pool_name'] in it) num_pg_active_clean = 0 - pg_dump = self.get('pg_dump') + pg_dump = ms.pg_dump for p in pg_dump['pg_stats']: pg_pool = p['pgid'].split('.')[0] if len(pool_ids) and int(pg_pool) not in pool_ids: