Clear file_lists caches on master start

The caches do expire quickly (30 sec by default), but if you make a
config change, then quickly restart the master, the caches will still be
younger than the expiry deadline. This commit clears all file lists
caches on master start to ensure that they are properly generated in the
first loop interval.
This commit is contained in:
Erik Johnson 2014-06-05 11:45:49 -05:00
parent ca9a5be2da
commit 0e25f0f8a6

View File

@ -5,9 +5,10 @@ involves preparing the three listeners and the workers needed by the master.
''' '''
# Import python libs # Import python libs
import fnmatch
import logging
import os import os
import re import re
import logging
import time import time
try: try:
import pwd import pwd
@ -76,7 +77,7 @@ def clean_fsbackend(opts):
''' '''
Clean out the old fileserver backends Clean out the old fileserver backends
''' '''
# Clear remote fileserver backend env cache so it gets recreated # Clear remote fileserver backend caches so they get recreated
for backend in ('git', 'hg', 'svn'): for backend in ('git', 'hg', 'svn'):
if backend in opts['fileserver_backend']: if backend in opts['fileserver_backend']:
env_cache = os.path.join( env_cache = os.path.join(
@ -94,6 +95,25 @@ def clean_fsbackend(opts):
.format(env_cache, exc) .format(env_cache, exc)
) )
file_lists_dir = os.path.join(
opts['cachedir'],
'file_lists',
'{0}fs'.format(backend)
)
try:
file_lists_caches = os.listdir(file_lists_dir)
except OSError:
continue
for file_lists_cache in fnmatch.filter(file_lists_caches, '*.p'):
cache_file = os.path.join(file_lists_dir, file_lists_cache)
try:
os.remove(cache_file)
except (IOError, OSError) as exc:
log.critical(
'Unable to file_lists cache file {0}: {1}'
.format(cache_file, exc)
)
def clean_expired_tokens(opts): def clean_expired_tokens(opts):
''' '''
@ -704,7 +724,7 @@ class RemoteFuncs(object):
if 'jid' in minion: if 'jid' in minion:
ret['__jid__'] = minion['jid'] ret['__jid__'] = minion['jid']
for key, val in self.local.get_cache_returns(ret['__jid__']).items(): for key, val in self.local.get_cache_returns(ret['__jid__']).items():
if not key in ret: if key not in ret:
ret[key] = val ret[key] = val
if load.get('form', '') != 'full': if load.get('form', '') != 'full':
ret.pop('__jid__') ret.pop('__jid__')