Skip to content

Allow user.present test mode with not-yet-existing groups (#68110)#69438

Open
dwoz wants to merge 1 commit into
saltstack:3006.xfrom
dwoz:fix/issue-68110
Open

Allow user.present test mode with not-yet-existing groups (#68110)#69438
dwoz wants to merge 1 commit into
saltstack:3006.xfrom
dwoz:fix/issue-68110

Conversation

@dwoz

@dwoz dwoz commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

user.present previously failed immediately with result: False and
"The following group(s) are not present: ..." whenever it was given a
groups: list that referenced a group not yet on the minion. That
happened even under state.apply test=True, which made it impossible to
preview states where the missing group is created by a group.present
requisite 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

foo:
  group.present: []
  user.present:
    - groups:
      - foo
    - require:
      - group: foo

salt '*' state.apply test=True returned result: False on the
user.present state with comment "The following group(s) are not
present: 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
result is None (changes would be made) instead of False (hard
error). Behavior in non-test mode is unchanged — a truly missing
required group is still a failure.

Merge requirements satisfied?

  • Docs
  • Changelog
  • Tests written/updated

Commits signed with GPG?

Yes

@dwoz dwoz requested a review from a team as a code owner June 12, 2026 01:00
@dwoz dwoz added this to the Sulphur v3006.26 milestone Jun 12, 2026
@dwoz dwoz added the test:full Run the full test suite label Jun 12, 2026
@dwoz dwoz force-pushed the fix/issue-68110 branch from e82dd70 to cece7c0 Compare June 14, 2026 02:09
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant