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

salt-call: don't re-use initial pillar if CLI overrides passed #46493

Merged
merged 1 commit into from Mar 12, 2018

Conversation

terminalmage
Copy link
Contributor

@terminalmage terminalmage commented Mar 12, 2018

A salt-call run already compiles pillar before executing the specified function. Therefore, a performance improvement was made to re-use that initial pillar data when running states. However, when we just re-use that pillar data, we lose the ability to have custom external pillar modules gain access to CLI pillar overrides. Therefore, this commit changes the code in the state compiler which gathers/re-uses the pillar data so that it only re-uses the existing in-memory pillar data when no CLI pillar overrides were passed.

Refs: 8d6fdb7, #44483

Fixes #46207

Use this walkthrough to check out the PR locally, and then the docker container below can be used to confirm the fix. All docker commands should be run from the root of the git clone of Salt.

Note that what the override doesn't make it into the initial calls to evaluate the ext_pillar, this is because these are run as salt-call is starting up. The final call comes as we're running the highstate though, and does indeed contain the CLI overrides.

% docker run --rm -it -v $PWD:/testing terminalmage/issues:46207
[root@512d8dd78ec8 /]# salt-master -d; salt-minion -d; sleep 10; salt-call state.highstate pillar='{"foo": "bar"}'; grep PILLAR /var/log/salt/master
local:
----------
          ID: echo bar
    Function: cmd.run
      Result: True
     Comment: Command "echo bar" run
     Started: 16:48:51.669426
    Duration: 376.983 ms
     Changes:
              ----------
              pid:
                  553
              retcode:
                  0
              stderr:
              stdout:
                  bar

Summary for local
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time: 376.983 ms
2018-03-12 16:48:51,119 [salt.loaded.ext.pillar.my_ext_pillar           :6   ][CRITICAL][55] PILLAR: {}
2018-03-12 16:48:51,171 [salt.loaded.ext.pillar.my_ext_pillar           :6   ][CRITICAL][55] PILLAR: {}
2018-03-12 16:48:51,349 [salt.loaded.ext.pillar.my_ext_pillar           :6   ][CRITICAL][47] PILLAR: {'foo': 'bar'}
[root@512d8dd78ec8 /]#

A salt-call run already compiles pillar before executing the specified
function. Therefore, a performance improvement was made to re-use that
initial pillar data when running states. However, when we just re-use
that pillar data, we lose the ability to have custom external pillar
modules gain access to CLI pillar overrides. Therefore, this commit
changes the code in the state compiler which gathers/re-uses the pillar
data so that it only re-uses the existing in-memory pillar data when no
CLI pillar overrides were passed.
@ghost ghost self-requested a review March 12, 2018 16:44
@terminalmage
Copy link
Contributor Author

terminalmage commented Mar 12, 2018

The above can be contrasted with running the same against 2017.7.4, and you can see we don't get the last call to compile the pillar data, so the pillar_overrides are never made available to the ext_pillar.

% git checkout -q v2017.7.4
% git describe
v2017.7.4
% docker run --rm -it -v $PWD:/testing terminalmage/issues:46207
[root@7090b5f7328a /]# salt-master -d; salt-minion -d; sleep 10; salt-call state.highstate pillar='{"foo": "bar"}'; grep PILLAR /var/log/salt/master
local:
----------
          ID: echo bar
    Function: cmd.run
      Result: True
     Comment: Command "echo bar" run
     Started: 16:57:07.832014
    Duration: 579.579 ms
     Changes:
              ----------
              pid:
                  541
              retcode:
                  0
              stderr:
              stdout:
                  bar

Summary for local
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
Total run time: 579.579 ms
2018-03-12 16:57:06,982 [salt.loaded.ext.pillar.my_ext_pillar           :6   ][CRITICAL][45] PILLAR: {}
2018-03-12 16:57:07,075 [salt.loaded.ext.pillar.my_ext_pillar           :6   ][CRITICAL][45] PILLAR: {}
[root@7090b5f7328a /]#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants