]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/balancer: add crush_compat_metrics param 25257/head
authorDan van der Ster <daniel.vanderster@cern.ch>
Sat, 15 Sep 2018 12:46:00 +0000 (14:46 +0200)
committerKonstantin Shalygin <k0ste@k0ste.ru>
Thu, 29 Nov 2018 01:42:08 +0000 (08:42 +0700)
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 <daniel.vanderster@cern.ch>
(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

index 529ee012d6124b9f1333982ad2e8ed1b49fe2423..ad44b5b3922121f44325afa6963222e65829ce7d 100644 (file)
@@ -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)