From 48a345cfc380e63105087de36d91df4728826bf5 Mon Sep 17 00:00:00 2001 From: Prashant D Date: Wed, 2 Sep 2020 08:33:16 -0400 Subject: [PATCH] mgr/mgr_module: fix keyerror for op If rule steps first element is opcode. Fixes: https://tracker.ceph.com/issues/47272 Signed-off-by: Prashant Dhange --- src/pybind/mgr/mgr_module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 9e8c3ba4ca6f..c30e5638c4f8 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -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 -- 2.47.3