Merge ~afreiberger/prometheus-openstack-exporter-snap:log-level-fix into prometheus-openstack-exporter-snap:master

Proposed by Drew Freiberger on 2019-11-14
Status: Merged
Merged at revision: 23f0cc580da3f9260c91097f62fe07ffd024e411
Proposed branch: ~afreiberger/prometheus-openstack-exporter-snap:log-level-fix
Merge into: prometheus-openstack-exporter-snap:master
Diff against target: 16 lines (+4/-1)
1 file modified
prometheus-openstack-exporter (+4/-1)
Reviewer Review Type Date Requested Status
James Hebden 2019-11-14 Pending
Canonical IS SAs 2019-11-14 Pending
Review via email: mp+375546@code.launchpad.net
To post a comment you must log in.
Drew Freiberger (afreiberger) wrote :

When upgrading to new P-O-E snap, if the log_level is not set in the config file (such as is the case with prior p-o-e charm revisions prior to this commit [1], the following traceback is seen and p-o-e fails to start:

Nov 14 12:13:40 loomis prometheus-openstack-exporter.prometheus-openstack-exporter[31476]: Traceback (most recent call last):
Nov 14 12:13:40 loomis prometheus-openstack-exporter.prometheus-openstack-exporter[31476]: File "/snap/prometheus-openstack-exporter/30/bin/prometheus-openstack-exporter", line 795, in <module>
Nov 14 12:13:40 loomis prometheus-openstack-exporter.prometheus-openstack-exporter[31476]: numeric_log_level = getattr(logging, config.get('log_level').upper(), None)
Nov 14 12:13:40 loomis prometheus-openstack-exporter.prometheus-openstack-exporter[31476]: AttributeError: 'NoneType' object has no attribute 'upper'

[1] https://git.launchpad.net/prometheus-openstack-exporter-charm/commit/templates/prometheus-openstack-exporter.yaml?id=f6b2f96dd0c4d4656de8384f1308fcac0fefa2ef

Haw Loeung (hloeung) wrote :

Ah, I actually ran into this when testing with the new snap from edge. But looking at the change, it was from 2 years ago so not sure why it suddenly broke things.

Good fix though!

However, I think the project moved to GitHub - https://github.com/CanonicalLtd/prometheus-openstack-exporter

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/prometheus-openstack-exporter b/prometheus-openstack-exporter
2index c2118d4..e02f727 100755
3--- a/prometheus-openstack-exporter
4+++ b/prometheus-openstack-exporter
5@@ -792,7 +792,10 @@ if __name__ == '__main__':
6 else:
7 log.addHandler(logging.StreamHandler())
8 config = yaml.safe_load(args.config_file.read())
9- numeric_log_level = getattr(logging, config.get('log_level').upper(), None)
10+ if config.get('log_level') is not None:
11+ numeric_log_level = getattr(logging, config.get('log_level').upper(), None)
12+ else
13+ numeric_log_level = getattr(logging, 'INFO', None)
14 if not isinstance(numeric_log_level, int):
15 raise ValueError('Invalid log level: %s' % config.get('log_level'))
16 log.setLevel(numeric_log_level)

Subscribers

People subscribed via source and target branches