From 3ffd9c2033d6ffa960f593987c8f24419ffe419c Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Tue, 18 Dec 2018 19:49:32 +0800 Subject: [PATCH] mgr/balancer: skip auto-balancing for pools with pending pg-merge This is racy and can lead to some corner cases which are hard to take care of... Signed-off-by: xie xingguo --- src/pybind/mgr/balancer/module.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py index 711922ddb23..27af772cae7 100644 --- a/src/pybind/mgr/balancer/module.py +++ b/src/pybind/mgr/balancer/module.py @@ -711,7 +711,12 @@ class Module(MgrModule): inc = plan.inc total_did = 0 left = max_iterations + pools_with_pg_merge = [p['pool_name'] for p in self.get_osdmap().dump().get('pools', []) + if p['pg_num'] > p['pg_num_target']] for pool in pools: + if pool in pools_with_pg_merge: + self.log.info('pool %s has pending PG(s) for merging, skipping for now' % pool) + continue did = ms.osdmap.calc_pg_upmaps(inc, max_deviation, left, [pool]) total_did += did left -= did @@ -719,7 +724,8 @@ class Module(MgrModule): break self.log.info('prepared %d/%d changes' % (total_did, max_iterations)) if total_did == 0: - return -errno.EALREADY, 'Unable to find further optimization,' \ + return -errno.EALREADY, 'Unable to find further optimization, ' \ + 'or pool(s)\' pg_num is decreasing, ' \ 'or distribution is already perfect' return 0, '' -- 2.39.5