]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
restful: Use node_id for _gather_leaf_ids 31272/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 00:38:38 +0000 (10:38 +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 b5e03b66849d51a75638da5c0d1ea09762b0e2ef..8f62b438b9400b606cdf8cf5ac8dbe916b4fdd9a 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']