Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pybind/mgr/prometheus: don't crash when encountering an unknown PG state #18903

Merged
merged 1 commit into from Nov 15, 2017

Conversation

jan--f
Copy link
Contributor

@jan--f jan--f commented Nov 13, 2017

Signed-off-by: Jan Fajerski jfajerski@suse.com

@@ -263,7 +263,10 @@ def get_pg_status(self):
key.split('+')]
for state, value in reported_pg_s:
path = 'pg_{}'.format(state)
self.metrics[path].set(value)
if path in self.metrics:
self.metrics[path].set(value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a little bit more pythonic+efficient to do this by doing a .get() and catching KeyError instead of doing the in test first

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes of course...thx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh my bad... .get() never throws a KeyError. So access via .[path] is needed to get the exception.

@jan--f jan--f force-pushed the jan-mgr-prometheus-unkown-pgstate branch from 8a43def to 8a00e9e Compare November 13, 2017 16:06
Signed-off-by: Jan Fajerski <jfajerski@suse.com>
@tchaikov tchaikov merged commit 78c7505 into ceph:master Nov 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants