From 8c93c0eeaff406af0878916ef5b9ce958896d586 Mon Sep 17 00:00:00 2001 From: Peter Woodman Date: Sat, 11 Nov 2017 16:32:37 -0800 Subject: [PATCH] mgr/prometheus: add missing 'deep' state to PG_STATES in ceph-mgr prometheus plugin without this the endpoint throws 500s when any PG is doing a deep scrub. Signed-off-by: Peter Woodman Fixes: http://tracker.ceph.com/issues/22116 --- src/pybind/mgr/prometheus/module.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index 80e8313d56e..07f53a63739 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -42,7 +42,7 @@ def health_status_to_number(status): elif status == 'HEALTH_ERR': return 2 -PG_STATES = ['creating', 'active', 'clean', 'down', 'scrubbing', 'degraded', +PG_STATES = ['creating', 'active', 'clean', 'down', 'scrubbing', 'deep', 'degraded', 'inconsistent', 'peering', 'repair', 'recovering', 'forced-recovery', 'backfill', 'forced-backfill', 'wait-backfill', 'backfill-toofull', 'incomplete', 'stale', 'remapped', 'undersized', 'peered'] @@ -266,12 +266,15 @@ class Module(MgrModule): try: self.metrics[path].set(value) except KeyError: - self.log.warn('Skipping unknown PG State {}'.format(state)) + self.log.warn("skipping pg in unknown state {}".format(state)) reported_states = [s[0] for s in reported_pg_s] for state in PG_STATES: path = 'pg_{}'.format(state) if state not in reported_states: - self.metrics[path].set(0) + try: + self.metrics[path].set(0) + except KeyError: + self.log.warn("skipping pg in unknown state {}".format(state)) def get_metadata_and_osd_status(self): osd_map = self.get('osd_map')