Ensure kwargs are sent along correctly to multiple sub proxies.

This commit is contained in:
Gareth J. Greenaway 2023-09-12 14:52:23 -07:00 committed by Megan Wilhite
parent 9927efba45
commit f2511ff711
3 changed files with 19 additions and 0 deletions

1
changelog/65179.fixed.md Normal file
View file

@ -0,0 +1 @@
Ensure kwarg arguments are sent along correctly. This change affects proxy minions when used with Deltaproxy, which had kwargs popped when targeting multiple minions id.

View file

@ -339,6 +339,7 @@ def load_args_and_kwargs(func, args, data=None, ignore_invalid=False):
# list of positional arguments. This keyword argument is
# invalid.
invalid_kwargs.append("{}={}".format(key, val))
arg.update({"__kwarg__": True})
continue
else:

View file

@ -8,6 +8,7 @@ import salt.ext.tornado
import salt.ext.tornado.gen
import salt.ext.tornado.testing
import salt.minion
import salt.modules.test as test_mod
import salt.syspaths
import salt.utils.crypt
import salt.utils.event as event
@ -1102,3 +1103,19 @@ async def test_syndic_async_req_channel(syndic_opts):
syndic.pub_channel = MagicMock()
syndic.tune_in_no_block()
assert isinstance(syndic.async_req_channel, salt.channel.client.AsyncReqChannel)
@pytest.mark.slow_test
def test_load_args_and_kwargs(minion_opts):
"""
Ensure load_args_and_kwargs performs correctly
"""
_args = [{"max": 40, "__kwarg__": True}]
ret = salt.minion.load_args_and_kwargs(test_mod.rand_sleep, _args)
assert ret == ([], {"max": 40})
assert all([True if "__kwarg__" in item else False for item in _args])
# Test invalid arguments
_args = [{"max_sleep": 40, "__kwarg__": True}]
with pytest.raises(salt.exceptions.SaltInvocationError):
ret = salt.minion.load_args_and_kwargs(test_mod.rand_sleep, _args)