Skip to content

pre-required state always runs twice regardless whether changes empty or not #52200

@angeloudy

Description

@angeloudy

According to the documentation

If the "changes" key contains a populated dictionary, it means that the pre-required state expects changes to occur when the state is actually executed, as opposed to the test-run. The pre-requiring state will now actually run. If the pre-requiring state executes successfully, the pre-required state will then execute. If the pre-requiring state fails, the pre-required state will not execute.

If the "changes" key contains an empty dictionary, this means that changes are not expected by the pre-required state. Neither the pre-required state nor the pre-requiring state will run.

The fact is that the pre-required state always runs whether there's any change or not.
The pre-requiring state only runs if changes are expected.

Lets make some clarification with the confusing terms used here:

test-a:
  salt.function:
    - name: service.stop
    - tgt: minion1
    - arg:
      - myservice
    - prereq:
      - test-b

test-b:
  salt.state:
    - tgt: minion1
    - sls:
      - mystate

In this example, test-a is the pre-requiring state, test-b is the pre-required state.
What happens it that test-b always run twice whether changes are expected or not.
Under normal situations, this doesn't hurt anything, but it would cause serious problem if test-a fail to generate changes in test mode, as in #49753 .

I know that the pchanges issue has already been fixed, but it would be nice to make prereq work as expected, or at least update the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending-discussionThe issue or pull request needs more discussion before it can be closed or mergedstale

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions