Merge pull request #27143 from cachedout/clean_grains_cache_on_sync

Clean grains cache on grains sync
This commit is contained in:
Erik Johnson 2015-09-16 11:27:06 -05:00
commit 38d93a96fe

View file

@ -161,6 +161,13 @@ def _sync(form, saltenv=None):
mod_file = os.path.join(__opts__['cachedir'], 'module_refresh')
with salt.utils.fopen(mod_file, 'a+') as ofile:
ofile.write('')
if form == 'grains' and \
__opts__.get('grains_cache') and \
os.path.isfile(os.path.join(__opts__['cachedir'], 'grains.cache.p')):
try:
os.remove(os.path.join(__opts__['cachedir'], 'grains.cache.p'))
except OSError:
log.error('Could not remove grains cache!')
return ret