]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/balancer: add crush_compat_metrics param 25291/head
authorDan van der Ster <daniel.vanderster@cern.ch>
Sat, 15 Sep 2018 12:46:00 +0000 (14:46 +0200)
committerNathan Cutler <ncutler@suse.com>
Tue, 27 Nov 2018 22:07:26 +0000 (23:07 +0100)
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)

src/pybind/mgr/balancer/module.py

index 8f0ea5fc84a59d22c57e8bd668b60eb58e588f03..68fc84b9bcb6de809f93efbdbe445ee7c4642e15 100644 (file)
@@ -206,6 +206,7 @@ class Module(MgrModule):
             {'name': 'active'},
             {'name': 'begin_time'},
             {'name': 'crush_compat_max_iterations'},
+            {'name': 'crush_compat_metrics'},
             {'name': 'crush_compat_step'},
             {'name': 'end_time'},
             {'name': 'max_misplaced'},
@@ -622,12 +623,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):
@@ -772,7 +777,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)