From 59a5f8413f5faf69e6357c6789865d0b7fb675e8 Mon Sep 17 00:00:00 2001 From: Tobias Urdin Date: Mon, 20 Jun 2022 15:14:33 +0000 Subject: [PATCH] mgr: influx: catch KeyError when looking up pool name It can lookup the pool name when a new pool is created and the pool_info doesn't contain it causing a KeyError. Signed-off-by: Tobias Urdin --- src/pybind/mgr/influx/module.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index 334b6c77f9f48..f88261b20b14b 100644 --- a/src/pybind/mgr/influx/module.py +++ b/src/pybind/mgr/influx/module.py @@ -233,11 +233,16 @@ class Module(MgrModule): def get_pg_summary_pool(self, pool_info: Dict[str, str], now: str) -> Iterator[Dict[str, Any]]: pool_sum = self.get('pg_summary')['by_pool'] for pool_id, stats in pool_sum.items(): + try: + pool_name = pool_info[pool_id] + except KeyError: + self.log.error('Unable to find pool name for pool {}'.format(pool_id)) + continue for stat in stats: yield { "measurement": "ceph_pg_summary_pool", "tags": { - "pool_name" : pool_info[pool_id], + "pool_name" : pool_name, "pool_id" : pool_id, "type_instance" : stat, }, -- 2.39.5