From 9dde3c9b73563cfe77cdb872746e1844287405e3 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Fri, 2 Feb 2018 15:12:49 +0800 Subject: [PATCH] pybind/mgr/balancer: allow customized optimization threshold 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 (cherry picked from commit 147625651fc712bcde3303ed8e9f6326dee1f6e7) --- src/pybind/mgr/balancer/module.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py index a615d4a4cbbcb..2a14dcae7f244 100644 --- a/src/pybind/mgr/balancer/module.py +++ b/src/pybind/mgr/balancer/module.py @@ -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 -- 2.39.5