]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/balancer: fix initial weight-set value for newly created osds
authorxie xingguo <xie.xingguo@zte.com.cn>
Thu, 9 May 2019 07:02:44 +0000 (15:02 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 29 May 2019 05:29:48 +0000 (13:29 +0800)
This is a follow-up fix for https://github.com/ceph/ceph/pull/26955,
which should make any OSD addition start with a zeroed weight-set weight.
But without this fix, the balancer won't be able to handle it properly..

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
(cherry picked from commit 64a4e7cdce71db446f47f3c36ac9df5d126ba29e)

src/pybind/mgr/balancer/module.py

index db8ea3c57c9d27dc6d5d0ff614fb5e4d20646a1d..a548604babca4ab861109f73dbf73c813acacc5f 100644 (file)
@@ -1050,8 +1050,12 @@ class Module(MgrModule):
                         if actual[osd] > 0:
                             calc_weight = target[osd] / actual[osd] * weight * ow
                         else:
-                            # not enough to go on here... keep orig weight
-                            calc_weight = weight / orig_osd_weight[osd]
+                            # for newly created osds, reset calc_weight at target value
+                            # this way weight-set will end up absorbing *step* of its
+                            # target (final) value at the very beginning and slowly catch up later.
+                            # note that if this turns out causing too many misplaced
+                            # pgs, then we'll reduce step and retry
+                            calc_weight = target[osd]
                         new_weight = weight * (1.0 - step) + calc_weight * step
                         self.log.debug('Reweight osd.%d %f -> %f', osd, weight,
                                        new_weight)