← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~harlowja/cloud-init/log-import-fail into lp:cloud-init

 

Joshua Harlow has proposed merging lp:~harlowja/cloud-init/log-import-fail into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~harlowja/cloud-init/log-import-fail/+merge/190225

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).
-- 
https://code.launchpad.net/~harlowja/cloud-init/log-import-fail/+merge/190225
Your team cloud init development team is requested to review the proposed merge of lp:~harlowja/cloud-init/log-import-fail into lp:cloud-init.
=== modified file 'cloudinit/importer.py'
--- cloudinit/importer.py	2012-06-21 06:40:00 +0000
+++ cloudinit/importer.py	2013-10-09 19:26:20 +0000
@@ -36,6 +36,7 @@
     found_places = []
     if not required_attrs:
         required_attrs = []
+    # NOTE(harlowja): translate the search paths to include the base name.
     real_paths = []
     for path in search_paths:
         real_path = []
@@ -50,8 +51,9 @@
         mod = None
         try:
             mod = import_module(full_path)
-        except ImportError:
-            pass
+        except ImportError as e:
+            LOG.debug("Failed at attempted import of '%s' due to: %s",
+                      full_path, e)
         if not mod:
             continue
         found_attrs = 0


Follow ups