From 67a1b66b06bf74274c2cf1d4b5c900f2c56a990d Mon Sep 17 00:00:00 2001 From: Jan Fajerski Date: Mon, 13 Nov 2017 14:42:56 +0100 Subject: [PATCH] pybind/mgr/prometheus: don't crash when encountering an unknown PG state Signed-off-by: Jan Fajerski --- src/pybind/mgr/prometheus/module.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index 842517f208f..80e8313d56e 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -263,7 +263,10 @@ class Module(MgrModule): key.split('+')] for state, value in reported_pg_s: path = 'pg_{}'.format(state) - self.metrics[path].set(value) + try: + self.metrics[path].set(value) + except KeyError: + self.log.warn('Skipping unknown PG State {}'.format(state)) reported_states = [s[0] for s in reported_pg_s] for state in PG_STATES: path = 'pg_{}'.format(state) -- 2.39.5