mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix show error report from salt.function
When no minions matched the default "No change made .." error was show rather than the No minions responded error.
This commit is contained in:
parent
95b4f6d14e
commit
387b82784e
3 changed files with 25 additions and 1 deletions
2
changelog/57920.fixed
Normal file
2
changelog/57920.fixed
Normal file
|
@ -0,0 +1,2 @@
|
|||
Set the comment to "No minions responded" if salt.function fails to find any
|
||||
minions
|
|
@ -577,7 +577,7 @@ def function(
|
|||
changes[minion] = m_ret
|
||||
if not cmd_ret:
|
||||
func_ret["result"] = False
|
||||
func_ret["command"] = "No minions responded"
|
||||
func_ret["comment"] = "No minions responded"
|
||||
else:
|
||||
if changes:
|
||||
func_ret["changes"] = {"out": "highstate", "ret": changes}
|
||||
|
|
|
@ -226,6 +226,28 @@ class SaltmodTestCase(TestCase, LoaderModuleMockMixin):
|
|||
with patch.dict(saltmod.__salt__, {"saltutil.cmd": mock_cmd}):
|
||||
self.assertDictEqual(saltmod.function(name, tgt), ret)
|
||||
|
||||
@slowTest
|
||||
def test_function_when_no_minions_match(self):
|
||||
"""
|
||||
Test to execute a single module function on a remote
|
||||
minion via salt or salt-ssh
|
||||
"""
|
||||
name = "state"
|
||||
tgt = "larry"
|
||||
mock_ret = {}
|
||||
mock_cmd = MagicMock(return_value=mock_ret)
|
||||
|
||||
ret = {
|
||||
"name": name,
|
||||
"changes": {},
|
||||
"result": False,
|
||||
"comment": "No minions responded",
|
||||
}
|
||||
|
||||
with patch.dict(saltmod.__opts__, {"test": False}):
|
||||
with patch.dict(saltmod.__salt__, {"saltutil.cmd": mock_cmd}):
|
||||
self.assertDictEqual(saltmod.function(name, tgt), ret)
|
||||
|
||||
# 'wait_for_event' function tests: 1
|
||||
|
||||
def test_wait_for_event(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue