Skip to content

Commit

Permalink
Fix parallel states on spawning platforms in general
Browse files Browse the repository at this point in the history
This was introduced by #66517

`__invocation_jid` is rewriten to `_State__invocation_id`, making
`cls(**init_kwargs)` fail with a TypeError (unexpected argument
`__invocation_jid` (this behavior is called name mangling).
  • Loading branch information
lkubb committed Oct 24, 2024
1 parent 8457d9b commit f3a49ca
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions salt/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,21 +753,21 @@ def __init__(
loader="states",
initial_pillar=None,
file_client=None,
__invocation_id=None,
_invocation_id=None,
):
"""
When instantiating an object of this class, do not pass
``__invocation_id``. It is an internal field for tracking
``_invocation_id``. It is an internal field for tracking
parallel executions where no jid is available (Salt-SSH) and
only exposed as an init argument to work on spawning platforms.
"""
if jid is not None:
__invocation_id = jid
if __invocation_id is None:
_invocation_id = jid
if _invocation_id is None:
# For salt-ssh parallel states, we need a unique identifier
# for a single execution. self.jid should not be set there
# since it's used for other purposes as well.
__invocation_id = salt.utils.jid.gen_jid(opts)
_invocation_id = salt.utils.jid.gen_jid(opts)
self._init_kwargs = {
"opts": opts,
"pillar_override": pillar_override,
Expand All @@ -778,7 +778,7 @@ def __init__(
"mocked": mocked,
"loader": loader,
"initial_pillar": initial_pillar,
"__invocation_id": __invocation_id,
"_invocation_id": _invocation_id,
}
self.states_loader = loader
if "grains" not in opts:
Expand Down Expand Up @@ -825,7 +825,7 @@ def __init__(
self.pre = {}
self.__run_num = 0
self.jid = jid
self.invocation_id = __invocation_id
self.invocation_id = _invocation_id
self.instance_id = str(id(self))
self.inject_globals = {}
self.mocked = mocked
Expand Down

0 comments on commit f3a49ca

Please sign in to comment.