Checking instance exists in master._get_cached_minion_data when cache.fetch returns None

This commit is contained in:
dharper 2017-02-24 13:59:52 -06:00 committed by rallytime
parent 855f87554c
commit ff6f63e9dd
3 changed files with 4 additions and 4 deletions

View file

@ -143,8 +143,8 @@ class Cache(object):
added by the driver itself.
:return:
Return a python object fetched from the cache or None if the given
path or key not found.
Return a python object fetched from the cache or and empty dict if
the given path or key not found.
:raises SaltCacheError:
Raises an exception if cache driver detected an error accessing data

View file

@ -104,7 +104,7 @@ def fetch(bank, key):
try:
_, value = api.kv.get(c_key)
if value is None:
return value
return {}
return __context__['serial'].loads(value['Value'])
except Exception as exc:
raise SaltCacheError(

View file

@ -61,7 +61,7 @@ def fetch(bank, key, cachedir):
key_file = os.path.join(cachedir, os.path.normpath(bank), '{0}.p'.format(key))
if not os.path.isfile(key_file):
log.debug('Cache file "%s" does not exist', key_file)
return None
return {}
try:
with salt.utils.fopen(key_file, 'rb') as fh_:
return __context__['serial'].load(fh_)