]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/balancer: allow customized optimization threshold
authorxie xingguo <xie.xingguo@zte.com.cn>
Fri, 2 Feb 2018 07:12:49 +0000 (15:12 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 7 Feb 2018 13:26:33 +0000 (21:26 +0800)
In practice it is hard to achieve a 100% (perfect) balanced distribution.
This patch introduces a user visiable threshold configuration here, which
allow user to define the minimal deviation to trigger an optimization.

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

index 9f1f1d07f873424ab047e2d76a3294b01c8293e1..a07ae8538257d2f174a78d4541f0ce245480a0ff 100644 (file)
@@ -697,8 +697,13 @@ class Module(MgrModule):
         osdmap = ms.osdmap
         crush = osdmap.get_crush()
         pe = self.calc_eval(ms, plan.pools)
-        if pe.score == 0:
-            detail = 'Distribution is already perfect'
+        min_score_to_optimize = float(self.get_config('min_score', 0))
+        if pe.score <= min_score_to_optimize:
+            if pe.score == 0:
+                detail = 'Distribution is already perfect'
+            else:
+                detail = 'score %f <= min_score %f, will not optimize' \
+                         % (pe.score, min_score_to_optimize)
             self.log.info(detail)
             return -errno.EALREADY, detail