Skip to content

Fix prereq chain misfire when an intermediate state reports test changes (#68438)#69376

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

Fix prereq chain misfire when an intermediate state reports test changes (#68438)#69376
dwoz wants to merge 1 commit into
saltstack:3006.xfrom
dwoz:fix/issue-68438

Conversation

@dwoz

@dwoz dwoz commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes a prereq chain bug where a state at the head of a chain
(state1 -prereq-> state2 -prereq-> state3) would always run when an
intermediate state in the chain always produces changes in test mode
(e.g. test.succeed_with_changes, module.run), even though the tail
state of the chain produced no changes.

What issues does this PR fix or reference?

Fixes #68438

Previous Behavior

For the chain in the issue:

state1:
  test.succeed_with_changes:
  - prereq:
    - test: state2

state2:
  test.succeed_with_changes:
  - prereq:
    - test: state3

state3:
  test.succeed_without_changes: []

state1 produced changes even though state3 reported no changes.

New Behavior

state1 reports no changes when the tail of the prereq chain reports no
changes, matching documented prereq semantics.

Merge requirements satisfied?

  • Used a personal fork of the source repository to submit this PR
  • Tests written/updated
  • Changelog entry
  • Documentation updated

Commits signed with GPG?

Yes

When a prereq chain is set up as

    state1 --prereq--> state2 --prereq--> state3

and state3 produces no changes, state1 should not run because its prereq
on state2 should also report no changes. The middle state was instead
unconditionally re-executed in test mode after its own prereq was
resolved, so any state that always pretends to change in test mode (e.g.
test.succeed_with_changes, module.run) caused the head of the chain to
run even though the tail produced no changes.

In State.call_chunk, when re-checking requisites for a low chunk flagged
__prereq__ after running its sub-requisites, treat a 'pre' status the
same way the non-prereq branch does: synthesize a no-changes result and
skip the state function call. This way the prerequiring caller sees
empty changes and does not run.

Fixes saltstack#68438
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