From: Jan Fajerski Date: Mon, 13 Nov 2017 13:42:56 +0000 (+0100) Subject: pybind/mgr/prometheus: don't crash when encountering an unknown PG state X-Git-Tag: v13.0.1~217^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F18903%2Fhead;p=ceph.git pybind/mgr/prometheus: don't crash when encountering an unknown PG state Signed-off-by: Jan Fajerski --- 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)