Pass cmd.run arguments to onlyif/unless cmd execution - #57825
Merged
Conversation
cmcmarrow
previously approved these changes
Jul 15, 2020
Contributor
|
From reading this patch it brings back Can this land as a (in my case urgent) bugfix for 3001 in the short term? |
garethgreenaway
previously approved these changes
Aug 24, 2020
Contributor
|
@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? |
mchugh19
dismissed stale reviews from garethgreenaway and cmcmarrow
via
August 29, 2020 08:53
0569037
Contributor
Author
|
@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. |
dwoz
approved these changes
Sep 8, 2020
Ch3LL
approved these changes
Sep 8, 2020
dwoz
approved these changes
Sep 8, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/bashwhich 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 argumentsbganduse_vtwould break functionality.Support of
shellis 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