]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/balancer: skip out/crush-out osds
authorxie xingguo <xie.xingguo@zte.com.cn>
Wed, 7 Mar 2018 03:14:12 +0000 (11:14 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Sat, 10 Mar 2018 03:44:01 +0000 (11:44 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
(cherry picked from commit 201fc98c358577ce7cef913068ba47d88b84931c)

src/pybind/mgr/balancer/module.py

index 1de206d25035add392687c70c8ffa3b743229971..bd493374d6076ce3b1da7e153537bc7f22519abb 100644 (file)
@@ -426,7 +426,7 @@ class Module(MgrModule):
         self.log.debug('pool_rule %s' % pool_rule)
 
         osd_weight = { a['osd']: a['weight']
-                       for a in ms.osdmap_dump.get('osds',[]) }
+                       for a in ms.osdmap_dump.get('osds',[]) if a['weight'] > 0 }
 
         # get expected distributions by root
         actual_by_root = {}
@@ -450,10 +450,11 @@ class Module(MgrModule):
             roots.append(root)
             weight_map = ms.crush.get_take_weight_osd_map(rootid)
             adjusted_map = {
-                osd: cw * osd_weight.get(osd, 1.0)
-                for osd,cw in weight_map.iteritems()
+                osd: cw * osd_weight[osd]
+                for osd,cw in weight_map.iteritems() if osd in osd_weight and cw > 0
             }
-            sum_w = sum(adjusted_map.values()) or 1.0
+            sum_w = sum(adjusted_map.values())
+            assert sum_w > 0
             pe.target_by_root[root] = { osd: w / sum_w
                                         for osd,w in adjusted_map.iteritems() }
             actual_by_root[root] = {