From 586545775bc4d874c6ca7133d14c1451acc55fe6 Mon Sep 17 00:00:00 2001 From: jeanluc Date: Thu, 24 Oct 2024 14:18:37 +0200 Subject: [PATCH] Fix parallel states on spawning platforms in general This was introduced by https://github.com/saltstack/salt/pull/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). --- salt/state.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/salt/state.py b/salt/state.py index e515e368b18..fc4f6d3a280 100644 --- a/salt/state.py +++ b/salt/state.py @@ -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, @@ -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: @@ -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