From: xie xingguo Date: Wed, 7 Mar 2018 03:14:12 +0000 (+0800) Subject: pybind/mgr/balancer: skip out/crush-out osds X-Git-Tag: v13.0.2~27^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=201fc98c358577ce7cef913068ba47d88b84931c;p=ceph.git pybind/mgr/balancer: skip out/crush-out osds Signed-off-by: xie xingguo --- diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py index faf5cfd1c50..09b2c5ec261 100644 --- a/src/pybind/mgr/balancer/module.py +++ b/src/pybind/mgr/balancer/module.py @@ -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] = {