Merge lp:~harlowja/cloud-init/log-import-fail into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Joshua Harlow
Status: Merged
Merged at revision: 897
Proposed branch: lp:~harlowja/cloud-init/log-import-fail
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 23 lines (+4/-2)
1 file modified
cloudinit/importer.py (+4/-2)
To merge this branch: bzr merge lp:~harlowja/cloud-init/log-import-fail
Reviewer Review Type Date Requested Status
cloud-init Commiters Pending
Review via email: mp+190225@code.launchpad.net

Description of the change

Add a log message around import failures.

Since the import failure can be an expected failure do not log that failure at a WARNING level, but to start log it at a DEBUG level. This will help in figuring out why imports fail (if they ever do) for developer and cloud-init users. Previously it is hard to know if a module fails importing for a valid reason (not existent) or an invalid reason (the module exists but the module has a dependency which is not satisfied).

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cloudinit/importer.py'
2--- cloudinit/importer.py 2012-06-21 06:40:00 +0000
3+++ cloudinit/importer.py 2013-10-09 19:26:20 +0000
4@@ -36,6 +36,7 @@
5 found_places = []
6 if not required_attrs:
7 required_attrs = []
8+ # NOTE(harlowja): translate the search paths to include the base name.
9 real_paths = []
10 for path in search_paths:
11 real_path = []
12@@ -50,8 +51,9 @@
13 mod = None
14 try:
15 mod = import_module(full_path)
16- except ImportError:
17- pass
18+ except ImportError as e:
19+ LOG.debug("Failed at attempted import of '%s' due to: %s",
20+ full_path, e)
21 if not mod:
22 continue
23 found_attrs = 0