From efca7925ef2cf6a1f3254ba7047a861e845ea499 Mon Sep 17 00:00:00 2001 From: Dan van der Ster Date: Sat, 15 Sep 2018 14:46:00 +0200 Subject: [PATCH] mgr/balancer: add crush_compat_metrics param Add a crush_compat_metrics options to allow choosing between pgs, objects, and bytes when rebalancing with crush-compat mode. Multi-values are supported, so that the placement scoring can be a function of several metrics. By default we score based on the mean of pgs, objects, and bytes scores for all roots. Signed-off-by: Dan van der Ster (cherry picked from commit 1f6866c15307a2a681d0e5c0293797da7fa5d1de) Conflicts: - path: src/pybind/mgr/balancer/module.py comment: luminous release don't have OPTIONS list --- src/pybind/mgr/balancer/module.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py index 529ee012d6124..ad44b5b392212 100644 --- a/src/pybind/mgr/balancer/module.py +++ b/src/pybind/mgr/balancer/module.py @@ -608,12 +608,16 @@ class Module(MgrModule): } self.log.debug('score_by_root %s' % pe.score_by_root) + # get the list of score metrics, comma separated + metrics = self.get_config('crush_compat_metrics', 'pgs,objects,bytes').split(',') + # total score is just average of normalized stddevs pe.score = 0.0 for r, vs in six.iteritems(pe.score_by_root): for k, v in six.iteritems(vs): - pe.score += v - pe.score /= 3 * len(roots) + if k in metrics: + pe.score += v + pe.score /= len(metrics) * len(roots) return pe def evaluate(self, ms, pools, verbose=False): @@ -756,7 +760,12 @@ class Module(MgrModule): self.log.error(detail) return -errno.EOPNOTSUPP, detail - key = 'pgs' # pgs objects or bytes + # rebalance by pgs, objects, or bytes + metrics = self.get_config('crush_compat_metrics', 'pgs,objects,bytes').split(',') + key = metrics[0] # balancing using the first score metric + if key not in ['pgs', 'bytes', 'objects']: + self.log.warn("Invalid crush_compat balancing key %s. Using 'pgs'." % key) + key = 'pgs' # go best_ws = copy.deepcopy(orig_ws) -- 2.39.5