-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Pass cmd.run arguments to onlyif/unless cmd execution #57825
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
Conversation
From reading this patch it brings back Can this land as a (in my case urgent) bugfix for 3001 in the short term? |
@mchugh19 LGTM, could you please run |
I would also agree with @jdelic - this breaks a lot for us. PowerShell is a lot different from cmd. Can we get this backported to 3001? |
0569037
@krionbsd @garethgreenaway since pre-commit ran the py2 cleanup process, and this touches state.py, it'd be nice to get lots of eyes on this. |
What does this PR do?
Extends the global onlyif/unless cmd handling to accept arguments defined in the cmd.run state.
What issues does this PR fix or reference?
Fixes: #57760
Previous Behavior
Previous to #55974, the cmd.run state handled its own unless and onlyif support. This included passing any of the cmd.run arguments for the state into the onlyif and unless cmd as well (https://github.com/saltstack/salt/pull/55974/files#diff-6617770c26f25c18a6adeeaf4ccdebd3L336)
When this behavior was removed in favor of using the global onlyif/unless requisites this behavior was not included, so arguments like
shell: /bin/bash
which were defined for cmd.run were not honored by the cmd.retcode execution used by onlyif/unless.New Behavior
Arguments accepted by cmd.run (which make sense) are now passed to cmd.retcode used by onlyif and unless.
Other possible arguments such as
name
,output_loglevel
, orcreates
, don't make sense for the unless/onlyif cmd.retcode use, while the argumentsbg
anduse_vt
would break functionality.Support of
shell
is a special case, and will be pulled first from the state arguments, then from the value of the shell grain if either exist.Risks: it is possible that generic terms like
cwd
,env
, orroot
, may exist in other states with different meanings than is intended for the cmd.retcode use in onlyif/unless. If desired, a gate could be added to optionally ignore inclusion of arguments to cmd.retcode, but has not yet been included as I don't know if the risk is worth the additional option complexity.Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
No