From f1f3014ffcc67200c20e6fb2b2e6e8f1141a0a1d Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 27 Sep 2017 15:12:36 -0400 Subject: [PATCH] mgr/balancer: stop if we get a perfect score ..and fix the 'worse' threshold (we're just working around floating point imprecision; 1.01 was too coarse). Signed-off-by: Sage Weil --- src/pybind/mgr/balancer/module.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py index b576cb6b16e..29f4b1d37f7 100644 --- a/src/pybind/mgr/balancer/module.py +++ b/src/pybind/mgr/balancer/module.py @@ -693,13 +693,15 @@ class Module(MgrModule): self.log.debug('Step misplaced %f > max %f, reducing step to %f', next_misplaced, max_misplaced, step) else: - if next_pe.score > cur_pe.score * 1.01: + if next_pe.score > cur_pe.score * 1.0001: step /= 2.0 self.log.debug('Score got worse, trying smaller step %f', step) else: cur_pe = next_pe best_ws = next_ws + if cur_pe.score == 0: + break left -= 1 if cur_pe.score < pe.score: -- 2.39.5