]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
restful: Use node_id for _gather_leaf_ids 31273/head
authorBoris Ranto <branto@redhat.com>
Fri, 25 Oct 2019 12:24:19 +0000 (14:24 +0200)
committerBrad Hubbard <bhubbard@redhat.com>
Thu, 31 Oct 2019 01:04:06 +0000 (11:04 +1000)
The _gather_leaf_ids function doesn't need the node structure, it only
needs the id.

Signed-off-by: Boris Ranto <branto@redhat.com>
(cherry picked from commit a325f28d93defbec48793060d6768204da94edd5)

src/pybind/mgr/restful/common.py

index 886d8accedd79f7d9c023882135c32c456fc7353..8906da9a3fad4f7e720adcd65beaec4ae909c207 100644 (file)
@@ -91,13 +91,13 @@ def pool_update_commands(pool_name, args):
 def crush_rule_osds(node_buckets, rule):
     nodes_by_id = dict((b['id'], b) for b in node_buckets)
 
-    def _gather_leaf_ids(node):
-        if node['id'] >= 0:
-            return set([node['id']])
+    def _gather_leaf_ids(node_id):
+        if node_id >= 0:
+            return set([node_id])
 
         result = set()
-        for item in nodes_by_id[node['id']]['items']:
-            result |= _gather_leaf_ids(item)
+        for item in nodes_by_id[node_id]['items']:
+            result |= _gather_leaf_ids(item['id'])
 
         return result
 
@@ -143,7 +143,7 @@ def crush_rule_osds(node_buckets, rule):
                         # Short circuit another iteration to find the emit
                         # and assume anything we've done a chooseleaf on
                         # is going to be part of the selected set of osds
-                        osds |= _gather_leaf_ids(desc_node)
+                        osds |= _gather_leaf_ids(desc_node['id'])
         elif step['op'] == 'emit':
             if root['id'] >= 0:
                 osds |= root['id']