Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid disk hit for renderer generation on pillar instantiation #36525

Merged
merged 1 commit into from
Sep 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions salt/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ def __init__(self, opts):
self.mminion = salt.minion.MasterMinion(
self.opts,
states=False,
rend=False,
rend=True,
ignore_config_errors=True
)
self.__setup_fileserver()
Expand Down Expand Up @@ -1326,7 +1326,8 @@ def _pillar(self, load):
load.get('saltenv', load.get('env')),
ext=load.get('ext'),
pillar=load.get('pillar_override', {}),
pillarenv=load.get('pillarenv'))
pillarenv=load.get('pillarenv'),
rend=self.mminion.rend)
data = pillar.compile_pillar(pillar_dirs=pillar_dirs)
self.fs_.update_opts()
if self.opts.get('minion_data_cache', False):
Expand Down
19 changes: 11 additions & 8 deletions salt/minion.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,14 +664,6 @@ def gen_modules(self, initial_load=False):
'''
Load all of the modules for the minion
'''
if self.opts.get('master_type') != 'disable':
self.opts['pillar'] = salt.pillar.get_pillar(
self.opts,
self.opts['grains'],
self.opts['id'],
self.opts['environment'],
pillarenv=self.opts.get('pillarenv'),
).compile_pillar()

self.utils = salt.loader.utils(self.opts)
self.functions = salt.loader.minion_mods(self.opts, utils=self.utils,
Expand All @@ -690,6 +682,17 @@ def gen_modules(self, initial_load=False):
self.functions['sys.reload_modules'] = self.gen_modules
self.executors = salt.loader.executors(self.opts)

if self.opts.get('master_type') != 'disable':
self.opts['pillar'] = salt.pillar.get_pillar(
self.opts,
self.opts['grains'],
self.opts['id'],
self.opts['environment'],
pillarenv=self.opts.get('pillarenv'),
funcs=self.functions,
rend=self.rend,
).compile_pillar()


class MasterMinion(object):
'''
Expand Down
13 changes: 8 additions & 5 deletions salt/pillar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


def get_pillar(opts, grains, minion_id, saltenv=None, ext=None, funcs=None,
pillar=None, pillarenv=None):
pillar=None, pillarenv=None, rend=None):
'''
Return the correct pillar driver based on the file_client option
'''
Expand All @@ -48,7 +48,7 @@ def get_pillar(opts, grains, minion_id, saltenv=None, ext=None, funcs=None,
return PillarCache(opts, grains, minion_id, saltenv, ext=ext, functions=funcs,
pillar=pillar, pillarenv=pillarenv)
return ptype(opts, grains, minion_id, saltenv, ext, functions=funcs,
pillar=pillar, pillarenv=pillarenv)
pillar=pillar, pillarenv=pillarenv, rend=rend)


# TODO: migrate everyone to this one!
Expand Down Expand Up @@ -123,7 +123,7 @@ class RemotePillar(object):
Get the pillar from the master
'''
def __init__(self, opts, grains, minion_id, saltenv, ext=None, functions=None,
pillar=None, pillarenv=None):
pillar=None, pillarenv=None, *args, **kwargs):
self.opts = opts
self.opts['environment'] = saltenv
self.ext = ext
Expand Down Expand Up @@ -259,7 +259,7 @@ class Pillar(object):
Read over the pillar top files and render the pillar data
'''
def __init__(self, opts, grains, minion_id, saltenv, ext=None, functions=None,
pillar=None, pillarenv=None):
pillar=None, pillarenv=None, rend=None):
self.minion_id = minion_id
# Store the file_roots path so we can restore later. Issue 5449
self.actual_file_roots = opts['file_roots']
Expand All @@ -281,7 +281,10 @@ def __init__(self, opts, grains, minion_id, saltenv, ext=None, functions=None,
self.functions = functions

self.matcher = salt.minion.Matcher(self.opts, self.functions)
self.rend = salt.loader.render(self.opts, self.functions)
if rend is None:
self.rend = salt.loader.render(self.opts, self.functions)
else:
self.rend = rend
ext_pillar_opts = copy.deepcopy(self.opts)
# Fix self.opts['file_roots'] so that ext_pillars know the real
# location of file_roots. Issue 5951
Expand Down