mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
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:
parent
ca9a5be2da
commit
0e25f0f8a6
@ -5,9 +5,10 @@ involves preparing the three listeners and the workers needed by the master.
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
import fnmatch
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import logging
|
||||
import time
|
||||
try:
|
||||
import pwd
|
||||
@ -76,7 +77,7 @@ def clean_fsbackend(opts):
|
||||
'''
|
||||
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'):
|
||||
if backend in opts['fileserver_backend']:
|
||||
env_cache = os.path.join(
|
||||
@ -94,6 +95,25 @@ def clean_fsbackend(opts):
|
||||
.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):
|
||||
'''
|
||||
@ -704,7 +724,7 @@ class RemoteFuncs(object):
|
||||
if 'jid' in minion:
|
||||
ret['__jid__'] = minion['jid']
|
||||
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
|
||||
if load.get('form', '') != 'full':
|
||||
ret.pop('__jid__')
|
||||
|
Loading…
Reference in New Issue
Block a user