From 1b4b061ed686d3546d2d2fc40627403e25b45a87 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Mon, 16 Dec 2019 13:54:50 +0800 Subject: [PATCH] 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 --- src/pybind/mgr/balancer/module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py index 9ea28735e7c50..041938a7471b3 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: -- 2.47.3