]> 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>
Wed, 7 Mar 2018 03:14:12 +0000 (11:14 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/pybind/mgr/balancer/module.py

index faf5cfd1c509f7dd0ff5e24cdbf009c5695522f7..09b2c5ec261aeaa651c76deb50416bd424b00878 100644 (file)
@@ -421,7 +421,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 = {}
@@ -445,10 +445,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] = {