Repository navigation
Prevent unnecessary duplicate pillar compilation - #41679
Conversation
|
@terminalmage, thanks for your PR! By analyzing the history of the files in this pull request, we identified @DmitryKuzmenko, @cachedout and @jacksontj to be potential reviewers. |
2e0fc7a to
4049783
Compare
|
@terminalmage It looks like some unit tests need to be looked at with this change: https://jenkins.saltstack.com/job/PR/job/salt-pr-rs-cent7-n/12060/#showFailuresLink |
|
@rallytime I just updated the tests. FYI for merge-forwards, you'll need to move the changes to the default |
|
@terminalmage finally got around to running this against my own environment and tests. This is much better! Thanks for working with me on this, looking forward to upgrading the rest of my minions 👍 |
|
@l2ol33rt Awesome. Thanks for testing it out and providing feedback. Glad we got this taken care of. I think we're close to getting it merged but it will unfortunately not make it into 2016.11.6. |
|
You're welcome! And no worries, I've got no problem running off a specific commit ID. |
456e95f to
6f200d4
Compare
d0d6608 to
f925bac
Compare
|
Some tests need to be updated again to reflect the changes I made on Friday to the saltenv/pillarenv normalization. |
659dcdf to
9594a78
Compare
This differentiates CLI pillar override with an eventual future "initial_pillar" argument which will seed the Pillar class with initial data.
This allows for salt.state.State() instances to have their initial pillar data passed into them, rather than calling _gather_pillar() to compile fresh pillar data. This allows for the __pillar__ dunder to be used directly for salt-call (when the pillarenv is unchanged). Since the __pillar__ is compiled at the beginning of a salt-call, this prevents duplicate pillar rendering from happening when salt-call is invoked.
This modifies the "state" exec module to use __pillar__ as the pillar data for the state run rather than compiling fresh pillar, unless the pillarenv has been changed from the configured value, keeping salt-call from unnecessarily compiling pillar a second time. It also normalizes saltenv/pillarenv support in functions that should have had it but did not.
This prevents an unnecessary pillar compile when syncing custom types, in cases where the saltenv is not specified.
9594a78 to
a916e8d
Compare
The
salt.state.HighStateclass' dunder init spawns asalt.state.Stateinstance, which in its own dunder init will compile fresh pillar data. However, there are two cases in particular where this results in unnecessary duplicate pillar compilation:salt-callsaltutil.sync_*To prevent this duplicate pillar generation, the
salt.state.Stateandsalt.state.HighStateclasses have been modified to accept a newinitial_pillarargument (the latter only to pass through to thesalt.state.Stateinstance). Ifinitial_pillaris set to a non-Nonevalue, then thesalt.state.Stateinstance will skip compiling pillar data and use the value passed instead.The
stateandsaltutilexecution modules now use thisinitial_pillarargument where applicable. There were actually a few functions in thestateexecution module which did not support saltenv/pillarenv, and the usage of these values has now been normalized. (Note to @rallytime for merge-forwards:_get_opts()now accepts double-asterisk kwargs instead of having the kwargs dict passed to it.)In addition, to differentiate initial pillar data from CLI pillar override data, I have changed references to the
pillarargument in pillar compilation (and all calls tosalt.pillar.get_pillar) topillar_override. This makes instantiatingsalt.states.Stateinstances make more sense, as it is confusing when you are passingpillarandinitial_pillararguments. Passingpillar_overrideandinitial_pillaris more explicit, and also paves the way for the planned eventual changes to pillar compilation which will allow the Pillar classes/subclasses to be seeded with initial data.