Skip to content

Commit b13ef14

Browse files
lkubbdwoz
authored andcommitted
Fix regular states requiring parallel ones
1 parent e9edb94 commit b13ef14

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

salt/state.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2688,7 +2688,14 @@ def _check_requisites(self, low: LowChunk, running: dict[str, dict[str, Any]]):
26882688
if run_dict_chunk:
26892689
filtered_run_dict[tag] = run_dict_chunk
26902690
run_dict = filtered_run_dict
2691-
pending = bool(not self.reconcile_procs(run_dict) and low.get("parallel"))
2691+
2692+
if low.get("parallel"):
2693+
pending = not self.reconcile_procs(run_dict)
2694+
else:
2695+
while True:
2696+
if self.reconcile_procs(run_dict):
2697+
break
2698+
time.sleep(0.01)
26922699

26932700
for chunk in chunks:
26942701
tag = _gen_tag(chunk)

tests/pytests/functional/modules/state/requisites/test_require.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,41 @@ def test_parallel_state_with_requires_on_parallel(state, state_tree):
601601
assert "__parallel__" in state_ret
602602

603603

604+
@pytest.mark.skip_on_windows
605+
def test_regular_state_requires_parallel(state, state_tree, tmp_path):
606+
"""
607+
Regular states requiring parallel states should block until all
608+
requisites are executed.
609+
"""
610+
tmpfile = tmp_path / "foo"
611+
sls_contents = f"""
612+
service_a:
613+
cmd.run:
614+
- name: sleep 3
615+
- parallel: True
616+
617+
service_b:
618+
cmd.run:
619+
- name: 'touch {tmpfile}'
620+
- parallel: True
621+
- require:
622+
- service_a
623+
624+
service_c:
625+
cmd.run:
626+
- name: 'test -f {tmpfile}'
627+
- require:
628+
- service_b
629+
"""
630+
631+
with pytest.helpers.temp_file("requisite_parallel_2.sls", sls_contents, state_tree):
632+
ret = state.sls(
633+
"requisite_parallel_2",
634+
__pub_jid="1", # Because these run in parallel we need a fake JID)
635+
)
636+
assert ret[f"cmd_|-service_c_|-test -f {tmpfile}_|-run"]["result"] is True
637+
638+
604639
def test_issue_59922_conflict_in_name_and_id_for_require_in(state, state_tree):
605640
"""
606641
Make sure that state_type is always honored while compiling down require_in to

0 commit comments

Comments
 (0)