From: Kefu Chai Date: Fri, 2 Feb 2018 07:57:14 +0000 (+0800) Subject: Merge pull request #20197 from xiexingguo/wip-load-ws-from-ms X-Git-Tag: v13.0.2~378 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=14a1035a5ebd6713b57aa18676cd9baec90bb0e7;p=ceph.git Merge pull request #20197 from xiexingguo/wip-load-ws-from-ms pybind/mgr/balancer: load weight-set from ms Reviewed-by: Sage Weil --- 14a1035a5ebd6713b57aa18676cd9baec90bb0e7 diff --cc src/pybind/mgr/balancer/module.py index 3d48cbba694,3233688e8e8..3b5d7f93790 --- a/src/pybind/mgr/balancer/module.py +++ b/src/pybind/mgr/balancer/module.py @@@ -819,35 -800,37 +819,38 @@@ class Module(MgrModule) else: self.log.info('Failed to find further optimization, score %f', pe.score) + plan.compat_ws = {} return False - def get_compat_weight_set_weights(self): - # enable compat weight-set - self.log.debug('ceph osd crush weight-set create-compat') - result = CommandResult('') - self.send_command(result, 'mon', '', json.dumps({ - 'prefix': 'osd crush weight-set create-compat', - 'format': 'json', - }), '') - r, outb, outs = result.wait() - if r != 0: - self.log.error('Error creating compat weight-set') - return - - result = CommandResult('') - self.send_command(result, 'mon', '', json.dumps({ - 'prefix': 'osd crush dump', - 'format': 'json', - }), '') - r, outb, outs = result.wait() - if r != 0: - self.log.error('Error dumping crush map') - return - try: - crushmap = json.loads(outb) - except: - raise RuntimeError('unable to parse crush map') + def get_compat_weight_set_weights(self, ms): + if '-1' not in ms.crush_dump.get('choose_args', {}): + # enable compat weight-set first + self.log.debug('ceph osd crush weight-set create-compat') + result = CommandResult('') + self.send_command(result, 'mon', '', json.dumps({ + 'prefix': 'osd crush weight-set create-compat', + 'format': 'json', + }), '') + r, outb, outs = result.wait() + if r != 0: + self.log.error('Error creating compat weight-set') + return + + result = CommandResult('') + self.send_command(result, 'mon', '', json.dumps({ + 'prefix': 'osd crush dump', + 'format': 'json', + }), '') + r, outb, outs = result.wait() + if r != 0: + self.log.error('Error dumping crush map') + return + try: + crushmap = json.loads(outb) + except: + raise RuntimeError('unable to parse crush map') + else: + crushmap = ms.crush_dump raw = crushmap.get('choose_args',{}).get('-1', []) weight_set = {}