Skip to content

Commit 0a6ec71

Browse files
committed
Fix syndic cluster mode timeout by enabling /new event forwarding
This fixes a regression introduced in commit 0643102 that prevented Salt CLI from exiting promptly when using syndics in cluster mode, causing 200+ second timeouts instead of the expected ~15 second completion. The issue had TWO related bugs: 1. **Syndic event forwarding logic (salt/minion.py)** - The syndic was setting return_event=False for ALL events with matching master_id, including /new events with minions lists - Changed to only set return_event=False for job RETURN events - Fixed salt.utils.jid.is_jid(mtag) check which failed for event tags like "salt/job/{jid}/new" (checks if entire string is JID, not if it contains one) - Now uses job_event variable which correctly identifies job events 2. **Master event blacklist logic (salt/daemons/masterapi.py)** - Minion event blacklist includes "salt/job/*/new" to prevent minions from spoofing job events - When syndics forward events with pretag="syndic/{id}", the pretagged event should bypass the blacklist as "syndic/{id}/salt/job/{jid}/new" - Bug: The `continue` statement skipped BOTH the original event AND the pretagged event when original tag was blacklisted - Fix: Fire pretagged event BEFORE checking blacklist, so syndic events are always forwarded with syndic/ prefix even if original tag is blacklisted Result: - Master of Masters now receives minions list from syndic via syndic/{id}/salt/job/{jid}/new events - Early-exit logic can trigger when all expected returns are received - test_syndic_target_single_minion now passes in ~40s instead of timing out at 200s
1 parent 5e4fa4b commit 0a6ec71

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

salt/daemons/masterapi.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -816,15 +816,19 @@ def _minion_event(self, load):
816816
event_data = event["data"]
817817
else:
818818
event_data = event
819-
if not valid_minion_tag(event["tag"]):
820-
log.warning("Filtering blacklisted event tag %s", event["tag"])
821-
continue
822-
self.event.fire_event(event_data, event["tag"]) # old dup event
819+
# Fire pretagged event first (for syndics) before blacklist check
820+
# This allows syndics to forward events like salt/job/*/new with
821+
# the syndic/ prefix, bypassing the minion event blacklist
823822
if load.get("pretag") is not None:
824823
self.event.fire_event(
825824
event_data,
826825
salt.utils.event.tagify(event["tag"], base=load["pretag"]),
827826
)
827+
# Check blacklist for original tag
828+
if not valid_minion_tag(event["tag"]):
829+
log.warning("Filtering blacklisted event tag %s", event["tag"])
830+
continue
831+
self.event.fire_event(event_data, event["tag"]) # old dup event
828832
else:
829833
tag = load["tag"]
830834
self.event.fire_event(load, tag)

salt/minion.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3901,8 +3901,14 @@ async def _process_event(self, raw):
39013901
):
39023902
job_event = True
39033903

3904-
if self.syndic_mode == "cluster" and data.get("master_id", 0) == self.opts.get(
3905-
"master_id", 1
3904+
# Only skip forwarding job RETURN events with matching master_id
3905+
# We must still forward /new events with minion lists so the master
3906+
# of masters knows which minions to expect returns from
3907+
if (
3908+
job_event
3909+
and tag_parts[3] == "ret"
3910+
and self.syndic_mode == "cluster"
3911+
and data.get("master_id", 0) == self.opts.get("master_id", 1)
39063912
):
39073913
return_event = False
39083914

@@ -3952,7 +3958,7 @@ async def _process_event(self, raw):
39523958
# Even in cluster mode we need to forward the raw event with the minions
39533959
# list to determine which minions we expect to return on the master of masters.
39543960
or (
3955-
return_event and (salt.utils.jid.is_jid(mtag) and "minions" in data)
3961+
return_event and job_event and "minions" in data
39563962
)
39573963
):
39583964
# Add generic event aggregation here

0 commit comments

Comments
 (0)