From fb05bd534b7263326d6689ec6080d0e7828e6d30 Mon Sep 17 00:00:00 2001 From: Jamie Bliss Date: Sun, 25 Nov 2018 23:19:55 -0500 Subject: [PATCH 1/3] Eat an exception from an entry point instead of letting it kill the system. --- salt/loader.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/salt/loader.py b/salt/loader.py index b4e7dbb70c04..c3cf963e6a65 100644 --- a/salt/loader.py +++ b/salt/loader.py @@ -160,9 +160,12 @@ def _module_dirs( ext_type_types.extend(opts[ext_type_dirs]) if HAS_PKG_RESOURCES and ext_type_dirs: for entry_point in pkg_resources.iter_entry_points('salt.loader', ext_type_dirs): - loaded_entry_point = entry_point.load() - for path in loaded_entry_point(): - ext_type_types.append(path) + try: + loaded_entry_point = entry_point.load() + for path in loaded_entry_point(): + ext_type_types.append(path) + except Exception: + log.exception("Error running entry point %r", entry_point) cli_module_dirs = [] # The dirs can be any module dir, or a in-tree _{ext_type} dir From 07868f1dfd19b2d3a095c626233a1dfd90527d22 Mon Sep 17 00:00:00 2001 From: Jamie Bliss Date: Wed, 28 Nov 2018 15:33:57 -0500 Subject: [PATCH 2/3] Improve logging output --- salt/loader.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/salt/loader.py b/salt/loader.py index c3cf963e6a65..5cfda4dc0ff3 100644 --- a/salt/loader.py +++ b/salt/loader.py @@ -138,6 +138,18 @@ def static_loader( return ret +def _format_entrypoint_target(ep): + """ + Makes a string describing the target of an EntryPoint object. + + Base strongly on EntryPoint.__str__(). + """ + s = ep.module_name + if ep.attrs: + s += ':' + '.'.join(ep.attrs) + return s + + def _module_dirs( opts, ext_type, @@ -164,8 +176,9 @@ def _module_dirs( loaded_entry_point = entry_point.load() for path in loaded_entry_point(): ext_type_types.append(path) - except Exception: - log.exception("Error running entry point %r", entry_point) + except Exception as exc: + log.error("Error getting module directories from %s: %s", _format_entrypoint_target(entry_point), exc) + log.debug("Full backtrace for module directories error", exc_info=True) cli_module_dirs = [] # The dirs can be any module dir, or a in-tree _{ext_type} dir From 869774480d7cfb04e654cf82f0526ac0a8b0e862 Mon Sep 17 00:00:00 2001 From: Jamie Bliss Date: Thu, 29 Nov 2018 22:51:29 -0500 Subject: [PATCH 3/3] Use single quotes per style guide --- salt/loader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/loader.py b/salt/loader.py index 5cfda4dc0ff3..3b7761194549 100644 --- a/salt/loader.py +++ b/salt/loader.py @@ -139,11 +139,11 @@ def static_loader( def _format_entrypoint_target(ep): - """ + ''' Makes a string describing the target of an EntryPoint object. Base strongly on EntryPoint.__str__(). - """ + ''' s = ep.module_name if ep.attrs: s += ':' + '.'.join(ep.attrs)