Allow user.present test mode with not-yet-existing groups (#68110)#69438
Open
dwoz wants to merge 1 commit into
Open
Allow user.present test mode with not-yet-existing groups (#68110)#69438dwoz wants to merge 1 commit into
dwoz wants to merge 1 commit into
Conversation
When `user.present` was given a `groups:` list containing a group that did not yet exist on the minion, it failed immediately with `result: False` and "The following group(s) are not present: ...", even under `state.apply test=True`. That made it impossible to preview states where the missing group is created by a `group.present` requisite in the same run. Gate the hard failure behind `not __opts__["test"]`. In test mode, drop missing groups from the membership comparison (they cannot be diffed against the user's current groups since they do not exist yet) and include them in the test-mode comment as pending so the operator can see what will change once the requisites run. Fixes saltstack#68110
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?
user.presentpreviously failed immediately withresult: Falseand"The following group(s) are not present: ..." whenever it was given a
groups:list that referenced a group not yet on the minion. Thathappened even under
state.apply test=True, which made it impossible topreview states where the missing group is created by a
group.presentrequisite in the same run.
This PR gates the hard failure on
not __opts__["test"]. In test mode,missing groups are dropped from the membership comparison (they cannot
be diffed against the user's current groups since they do not exist
yet) and added to the test-mode comment as pending so the operator can
still see what would change.
What issues does this PR fix or reference?
Fixes #68110
Previous Behavior
salt '*' state.apply test=Truereturnedresult: Falseon theuser.presentstate with comment "The following group(s) are notpresent: foo", even though the group would have been created during a
real run.
New Behavior
In test mode, the missing group is reported as pending; the state's
resultisNone(changes would be made) instead ofFalse(harderror). Behavior in non-test mode is unchanged — a truly missing
required group is still a failure.
Merge requirements satisfied?
Commits signed with GPG?
Yes