From e50a50cf10dc4abd2af385840db104285dbffebc Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Fri, 2 Feb 2018 15:24:21 +0800 Subject: [PATCH] pybind/mgr/balancer: cancel plan if distribution is already perfect Signed-off-by: xie xingguo (cherry picked from commit 3da5257a675e966e9b5748dc35373fc078c61a87) --- src/pybind/mgr/balancer/module.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py index 2a14dcae7f244..bf8d1143c8edd 100644 --- a/src/pybind/mgr/balancer/module.py +++ b/src/pybind/mgr/balancer/module.py @@ -679,6 +679,9 @@ class Module(MgrModule): if left <= 0: break self.log.info('prepared %d/%d changes' % (total_did, max_iterations)) + if total_did == 0: + return -errno.EALREADY, 'Unable to find further optimization,' \ + 'or distribution is already perfect' return 0, '' def do_crush_compat(self, plan): -- 2.39.5