]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
mgr/restful: fix py got exception when get osd info 21138/head
authorzouaiguo <zou.aiguo@zte.com.cn>
Fri, 30 Mar 2018 08:20:22 +0000 (16:20 +0800)
committerclove <clove@zte.com.cn>
Thu, 29 Nov 2018 05:25:31 +0000 (13:25 +0800)
commit23b6c904941444f0bebb912e7dd069f2d2b1f44a
tree5c26a9dc549471555bb44f22a79721f165ebc69b
parent9e8af3e243185df3e9319f987e472039e15e7d4d
mgr/restful: fix py got exception when get osd info

when we create pool by device class, then get osd info by restful,
such as https://192.7.7.36:8003/osd
browser display error, and found excetion in /var/log/ceph/ceph-mgr****.log

2018-03-30 16:07:52.756560 7feef9f17700  0 mgr[restful] Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pecan/core.py", line 570, in __call__
    self.handle_request(req, resp)
  File "/usr/lib/python2.7/site-packages/pecan/core.py", line 508, in handle_request
    result = controller(*args, **kwargs)
  File "/usr/lib64/ceph/mgr/restful/decorators.py", line 33, in decorated
    return f(*args, **kwargs)
  File "/usr/lib64/ceph/mgr/restful/api/osd.py", line 130, in get
    return module.instance.get_osds(pool_id)
  File "/usr/lib64/ceph/mgr/restful/module.py", line 543, in get_osds
    pools_map = self.get_osd_pools()
  File "/usr/lib64/ceph/mgr/restful/module.py", line 516, in get_osd_pools
    pool_osds = common.crush_rule_osds(self.get('osd_map_tree')['nodes'], rule)
  File "/usr/lib64/ceph/mgr/restful/common.py", line 149, in crush_rule_osds
    osds |= _gather_osds(nodes_by_id[step['item']], rule['steps'][i + 1:])
KeyError: -8L

buckets in osd_map_crush has more infomation than nodes in osd_map_tree
so we can use buckets instead op nodes to get rule osds

Signed-off-by: zouaiguo <zou.aiguo@zte.com.cn>
src/pybind/mgr/restful/api/crush.py
src/pybind/mgr/restful/common.py
src/pybind/mgr/restful/module.py