Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requisite_any: dont fall in an infinite loop when req doesnt exist #55777

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions salt/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -3170,17 +3170,8 @@ def call_chunk(self, low, running, chunks, depth=0):
found = True
if not found:
lost[requisite].append(req)
if (
lost["require"]
or lost["watch"]
or lost["prereq"]
or lost["onfail"]
or lost["onchanges"]
or lost["require_any"]
or lost["watch_any"]
or lost["onfail_any"]
or lost["onchanges_any"]
or lost.get("prerequired")
if set(lost.keys()) & (
STATE_REQUISITE_KEYWORDS | STATE_REQUISITE_IN_KEYWORDS
):
comment = "The following requisites were not found:\n"
for requisite, lreqs in lost.items():
Expand Down
23 changes: 23 additions & 0 deletions tests/pytests/functional/modules/state/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,3 +1081,26 @@ def test_state_sls_mock_ret(state_tree):
ret["cmd_|-echo1_|-echo 'This is a test!'_|-run"]["comment"]
== "Not called, mocked"
)


def test_state_requires_missing(state, state_tree):
"""
this tests missing requisites are found as expected
"""
sls_contents = """
changing_state:
cmd.run:
- name: echo "Changed!"
missing_prereq:
cmd.run:
- name: echo "Changed!"
- onchanges_any:
- this: is missing
- onchanges:
- also: missing
"""
with pytest.helpers.temp_file("req_any_missing.sls", sls_contents, state_tree):
ret = state.sls("req_any_missing")
state_id = 'cmd_|-changing_state_|-echo "Changed!"_|-run'
assert state_id in ret
assert ret[state_id]["result"] is True
Loading