]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/mgr_module: fix keyerror for op 36947/head
authorPrashant D <pdhange@redhat.com>
Wed, 2 Sep 2020 12:33:16 +0000 (08:33 -0400)
committerPrashant D <pdhange@redhat.com>
Fri, 4 Sep 2020 11:39:45 +0000 (07:39 -0400)
If rule steps first element is opcode.

Fixes: https://tracker.ceph.com/issues/47272
Signed-off-by: Prashant Dhange <pdhange@redhat.com>
src/pybind/mgr/mgr_module.py

index 9e8c3ba4ca6fb6e8145e05a3140cc4cd52b75612..c30e5638c4f8311c14c301c9f3aa5f16c90ec1ce 100644 (file)
@@ -234,8 +234,8 @@ class CRUSHMap(ceph_module.BasePyCRUSH):
             return None
 
         try:
-            first_take = [s for s in rule['steps'] if s['op'] == 'take'][0]
-        except IndexError:
+            first_take = next(s for s in rule['steps'] if s.get('op') == 'take')
+        except StopIteration:
             logging.warning("CRUSH rule '{0}' has no 'take' step".format(
                 rule_name))
             return None