Merge pull request #16358 from cachedout/gate_minion_cache

Flag to preserve minion cache on key delete
This commit is contained in:
Thomas S Hatch 2014-10-03 12:26:10 -06:00
commit 7001e20441
3 changed files with 14 additions and 3 deletions

View File

@ -137,6 +137,14 @@
# 'aes_key_rotate' event with the 'key' tag and acting appropriately. # 'aes_key_rotate' event with the 'key' tag and acting appropriately.
# ping_on_rotate: False # ping_on_rotate: False
# By default, the master deletes its cache of minion data when the key for that
# minion is removed. To preserve the cache after key deletion, set
# 'preserve_minion_cache' to True.
#
# WARNING: This may have security implications if compromised minions auth with
# a previous deleted minion ID.
#preserve_minion_cache: False
# If max_minions is used in large installations, the master might experience # If max_minions is used in large installations, the master might experience
# high-load situations because of having to check the number of connected # high-load situations because of having to check the number of connected
# minions for every authentication. This cache provides the minion-ids of # minions for every authentication. This cache provides the minion-ids of

View File

@ -186,6 +186,7 @@ VALID_OPTS = {
'pillar_source_merging_strategy': str, 'pillar_source_merging_strategy': str,
'ping_on_key_rotate': bool, 'ping_on_key_rotate': bool,
'peer': dict, 'peer': dict,
'preserve_minion_cache': bool,
'syndic_master': str, 'syndic_master': str,
'runner_dirs': list, 'runner_dirs': list,
'client_acl': dict, 'client_acl': dict,
@ -474,6 +475,7 @@ DEFAULT_MASTER_OPTS = {
'pillar_source_merging_strategy': 'smart', 'pillar_source_merging_strategy': 'smart',
'ping_on_key_rotate': False, 'ping_on_key_rotate': False,
'peer': {}, 'peer': {},
'preserve_minion_cache': False,
'syndic_master': '', 'syndic_master': '',
'runner_dirs': [], 'runner_dirs': [],
'outputter_dirs': [], 'outputter_dirs': [],

View File

@ -475,6 +475,7 @@ class Key(object):
minions = [] minions = []
for key, val in keys.items(): for key, val in keys.items():
minions.extend(val) minions.extend(val)
if self.opts.get('preserve_minion_cache', False):
for minion in os.listdir(m_cache): for minion in os.listdir(m_cache):
if minion not in minions: if minion not in minions:
shutil.rmtree(os.path.join(m_cache, minion)) shutil.rmtree(os.path.join(m_cache, minion))