]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/balancer: skip auto-balancing for pools with pending pg-merge
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 18 Dec 2018 11:49:32 +0000 (19:49 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 19 Dec 2018 07:19:32 +0000 (15:19 +0800)
This is racy and can lead to some corner cases which are hard to
take care of...

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/pybind/mgr/balancer/module.py

index 711922ddb233a100c805fdd0fd8dabe4c0a2ad02..27af772cae792883033684dc24b9bf90f798e1ef 100644 (file)
@@ -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, ''