Skip to content

fix(minion): run own job when target id equals a managed resource id - #69868

Open
n0liu wants to merge 1 commit into
saltstack:3008.xfrom
n0liu:fix/minion-self-job-resource-id-collision
Open

fix(minion): run own job when target id equals a managed resource id#69868
n0liu wants to merge 1 commit into
saltstack:3008.xfrom
n0liu:fix/minion-self-job-resource-id-collision

Conversation

@n0liu

@n0liu n0liu commented Jul 25, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes #69867.

When a minion's own id is also one of its managed resource ids, a bare (wildcard-free) glob target equal to that id is misclassified as a pure resource target. _target_load then sets minion_is_target to False, so the minion dispatches the job to the matching resource but skips running it on itself.

The offending branch in Minion._is_pure_resource_target matches any bare glob against every managed resource id without excluding the minion's own id:

if (
    tgt_type == "glob"
    and isinstance(tgt, str)
    and not any(c in tgt for c in ("*", "?", "[")):
):
    resources = self.opts.get("resources", {})
    for rids in resources.values():
        if tgt in rids:
            return True

How does this PR fix it?

Exclude the minion's own id from that bare-id match:

    and tgt != self.opts.get("id")

A target equal to the minion's own id is therefore no longer "pure resource", so minion_is_target stays True and the minion runs the job locally in addition to dispatching it to the resource. A bare id that is only a resource id (not the minion's own) is unaffected.

Tests

Added test_pure_resource_target_excludes_own_minion_id in tests/pytests/unit/test_minion_resources.py. It builds a minion whose id (dummy-01) is also a managed resource id and asserts:

  • _is_pure_resource_target is False for the own-id target (fails before this change, passes after),
  • and still True for a different resource id (dummy-02), guarding against over-correction.

python -m pytest tests/pytests/unit/test_minion_resources.py — 62 passed locally.

@n0liu
n0liu requested a review from a team as a code owner July 25, 2026 08:59

@twangboy twangboy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. We fix bugs on the earliest branch where the bug exists. Resources were added in 3008. Please rebase this on the the 3008.x branch.

@twangboy twangboy added the test:full Run the full test suite label Jul 27, 2026
@twangboy twangboy added this to the Argon v3008.3 milestone Jul 27, 2026
@n0liu
n0liu force-pushed the fix/minion-self-job-resource-id-collision branch from 76e7891 to 377758b Compare July 28, 2026 03:42
@n0liu
n0liu changed the base branch from master to 3008.x July 28, 2026 03:42
@n0liu

n0liu commented Jul 28, 2026

Copy link
Copy Markdown
Author

Thanks for the review, @twangboy! Done — I've rebased this onto 3008.x and retargeted the PR base to that branch.

I re-verified the fix on 3008.x: _is_pure_resource_target's bare-id glob branch is present there and still exhibits the bug (returns True for the minion's own id when it collides with a managed resource id). With the fix, tests/pytests/unit/test_minion_resources.py passes (62 passed); removing the one-line guard makes test_pure_resource_target_excludes_own_minion_id fail as expected.

When a minion's own id is also one of its managed resource ids, a bare
(wildcard-free) glob target equal to that id was classified as a pure
resource target. `_target_load` then set `minion_is_target` to False, so
the minion dispatched the job to the resource but skipped running it
locally.

Exclude the minion's own id from the bare-id resource match in
`_is_pure_resource_target`, so such a target is no longer pure-resource
and the minion runs the job itself in addition to the resource.

Fixes saltstack#69867
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.

[Bug]: Minion skips own job when target id equals a managed resource id

2 participants