Project

General

Profile

Bug #48488

mgr/restful: _gather_osds() mistakenly treats a `str` as a `dict`

Added by Jerry Pu 4 months ago. Updated about 1 month ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
restful module
Target version:
-
% Done:

0%

Source:
Tags:
low-hanging-fruit
Backport:
nautilus, octopus
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

2020-12-08T11:18:29.238+0800 7fe03c4d2700  0 [restful ERROR werkzeug] Error on request:
Traceback (most recent call last):
  File "/usr/local/lib64/python3.6/site-packages/werkzeug/serving.py", line 323, in run_wsgi
    execute(self.server.app)
  File "/usr/local/lib64/python3.6/site-packages/werkzeug/serving.py", line 312, in execute
    application_iter = app(environ, start_response)
  File "/usr/local/lib/python3.6/site-packages/pecan/middleware/recursive.py", line 56, in __call__
    return self.application(environ, start_response)
  File "/usr/local/lib/python3.6/site-packages/pecan/core.py", line 852, in __call__
    return super(Pecan, self).__call__(environ, start_response)
  File "/usr/local/lib/python3.6/site-packages/pecan/core.py", line 693, in __call__
    self.invoke_controller(controller, args, kwargs, state)
  File "/usr/local/lib/python3.6/site-packages/pecan/core.py", line 584, in invoke_controller
    result = controller(*args, **kwargs)
  File "/usr/share/ceph/mgr/restful/decorators.py", line 59, in decorated
    return f(*args, **kwargs)
  File "/usr/share/ceph/mgr/restful/api/crush.py", line 21, in get
    rule['osd_count'] = len(common.crush_rule_osds(crush['buckets'], rule))
  File "/usr/share/ceph/mgr/restful/common.py", line 159, in crush_rule_osds
    osds |= _gather_osds(nodes_by_id[step['item']], rule['steps'][i + 1:])
  File "/usr/share/ceph/mgr/restful/common.py", line 135, in _gather_osds
    osds |= _gather_osds(desc_node, steps[1:])
  File "/usr/share/ceph/mgr/restful/common.py", line 122, in _gather_osds
    if root['id'] >= 0:
TypeError: string indices must be integers

In _gather_osds() processing `choose_firstn`, it tries to traverse the keys of a `dict` (nodes_by_id[node_id]) which is not a real node, thus mistakenly passing `str` to _gather_osds() to do recursion.

I am working on this to create a pr and sorry for the duplicate ticket #48487


Related issues

Duplicated by mgr - Bug #48487: mgr/restful: TypeError: string indices must be integers in _gather_osds Duplicate
Copied to mgr - Backport #48557: octopus: mgr/restful: _gather_osds() mistakenly treats a `str` as a `dict` Resolved
Copied to mgr - Backport #48558: nautilus: mgr/restful: _gather_osds() mistakenly treats a `str` as a `dict` Resolved

History

#2 Updated by Kefu Chai 4 months ago

  • Status changed from New to Fix Under Review
  • Assignee set to Jerry Pu
  • Backport set to nautilus, octopus
  • Pull request ID set to 38480

#3 Updated by Kefu Chai 4 months ago

  • Status changed from Fix Under Review to Pending Backport

#4 Updated by Backport Bot 4 months ago

  • Copied to Backport #48557: octopus: mgr/restful: _gather_osds() mistakenly treats a `str` as a `dict` added

#5 Updated by Backport Bot 4 months ago

  • Copied to Backport #48558: nautilus: mgr/restful: _gather_osds() mistakenly treats a `str` as a `dict` added

#6 Updated by Nathan Cutler 4 months ago

  • Tags set to low-hanging-fruit

#7 Updated by Nathan Cutler 4 months ago

  • Duplicated by Bug #48487: mgr/restful: TypeError: string indices must be integers in _gather_osds added

#8 Updated by Ernesto Puerta about 2 months ago

  • Tags set to low-hanging-fruit

#9 Updated by Nathan Cutler about 1 month ago

  • Status changed from Pending Backport to Resolved

While running with --resolve-parent, the script "backport-create-issue" noticed that all backports of this issue are in status "Resolved" or "Rejected".

Also available in: Atom PDF