Add error logging when whitelist lookup fails

Rather than just raising a bare KeyError with no additional information,
this raises a proper KeyError with the key that failed to be looked up.
It also logs the key that failed to load, as well as the whitelist, to
aid in troubleshooting.
This commit is contained in:
Erik Johnson 2018-05-17 16:41:36 -05:00
parent cb04d9c37e
commit d4f2662e5b
No known key found for this signature in database
GPG key ID: 5E5583C437808F3F

View file

@ -1629,7 +1629,11 @@ class LazyLoader(salt.utils.lazy.LazyDict):
return True
# if the modulename isn't in the whitelist, don't bother
if self.whitelist and mod_name not in self.whitelist:
raise KeyError
log.error(
'Failed to load key %s because its module (%s) is not in '
'the whitelist: %s', key, mod_name, self.whitelist
)
raise KeyError(key)
def _inner_load(mod_name):
for name in self._iter_files(mod_name):