mirror of
https://github.com/ceph/ceph
synced 2024-12-28 14:34:13 +00:00
Merge pull request #20258 from tchaikov/wip-balancer-cleanup
mgr/balancer: replace magic value of -1 for DEFAULT_CHOOSE_ARGS Reviewed-by: xie xingguo <xie.xingguo@zte.com.cn> Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
commit
b813b13306
@ -77,7 +77,7 @@ class Plan:
|
||||
self.initial.osdmap.get_crush_version())
|
||||
ls.append('# mode %s' % self.mode)
|
||||
if len(self.compat_ws) and \
|
||||
'-1' not in self.initial.crush_dump.get('choose_args', {}):
|
||||
not CRUSHMap.have_default_choose_args(self.initial.crush_dump):
|
||||
ls.append('ceph osd crush weight-set create-compat')
|
||||
for osd, weight in self.compat_ws.iteritems():
|
||||
ls.append('ceph osd crush weight-set reweight-compat %s %f' %
|
||||
@ -842,7 +842,7 @@ class Module(MgrModule):
|
||||
return False
|
||||
|
||||
def get_compat_weight_set_weights(self, ms):
|
||||
if '-1' not in ms.crush_dump.get('choose_args', {}):
|
||||
if not CRUSHMap.have_default_choose_args(ms.crush_dump):
|
||||
# enable compat weight-set first
|
||||
self.log.debug('ceph osd crush weight-set create-compat')
|
||||
result = CommandResult('')
|
||||
@ -871,7 +871,7 @@ class Module(MgrModule):
|
||||
else:
|
||||
crushmap = ms.crush_dump
|
||||
|
||||
raw = crushmap.get('choose_args',{}).get('-1', [])
|
||||
raw = CRUSHMap.get_default_choose_args(crushmap)
|
||||
weight_set = {}
|
||||
for b in raw:
|
||||
bucket = None
|
||||
@ -904,7 +904,7 @@ class Module(MgrModule):
|
||||
|
||||
# compat weight-set
|
||||
if len(plan.compat_ws) and \
|
||||
'-1' not in plan.initial.crush_dump.get('choose_args', {}):
|
||||
not CRUSHMap.have_default_choose_args(plan.initial.crush_dump):
|
||||
self.log.debug('ceph osd crush weight-set create-compat')
|
||||
result = CommandResult('')
|
||||
self.send_command(result, 'mon', '', json.dumps({
|
||||
|
@ -125,6 +125,7 @@ class OSDMapIncremental(ceph_module.BasePyOSDMapIncremental):
|
||||
|
||||
class CRUSHMap(ceph_module.BasePyCRUSH):
|
||||
ITEM_NONE = 0x7fffffff
|
||||
DEFAULT_CHOOSE_ARGS = '-1'
|
||||
|
||||
def dump(self):
|
||||
return self._dump()
|
||||
@ -142,6 +143,15 @@ class CRUSHMap(ceph_module.BasePyCRUSH):
|
||||
uglymap = self._get_take_weight_osd_map(root)
|
||||
return { int(k): v for k, v in uglymap.get('weights', {}).iteritems() }
|
||||
|
||||
@staticmethod
|
||||
def have_default_choose_args(dump):
|
||||
return CRUSHMap.DEFAULT_CHOOSE_ARGS in dump.get('choose_args', {})
|
||||
|
||||
@staticmethod
|
||||
def get_default_choose_args(dump):
|
||||
return dump.get('choose_args').get(CRUSHMap.DEFAULT_CHOOSE_ARGS, [])
|
||||
|
||||
|
||||
class MgrStandbyModule(ceph_module.BaseMgrStandbyModule):
|
||||
"""
|
||||
Standby modules only implement a serve and shutdown method, they
|
||||
|
Loading…
Reference in New Issue
Block a user