diff --git a/salt/modules/transactional_update.py b/salt/modules/transactional_update.py index 07c19d8d9c..20cafda46c 100644 --- a/salt/modules/transactional_update.py +++ b/salt/modules/transactional_update.py @@ -990,14 +990,16 @@ def call(function, *args, **kwargs): finally: # Check if reboot is needed if (activate_transaction and pending_transaction()) or ( - not kwargs.get("test", False) and _user_specified_reboot(local) + not kwargs.get("test", False) and _user_specified_reboot(local, function) ): reboot() -def _user_specified_reboot(local): +def _user_specified_reboot(local, function): + if function != "state.highstate" and function != "state.sls": + return False + if not isinstance(local, dict): - # Skip if execution is not state/highstate return False explicit_reboot_cmds = set(["reboot", "system.reboot"]) diff --git a/tests/pytests/unit/modules/test_transactional_update.py b/tests/pytests/unit/modules/test_transactional_update.py index 1783f2628c..8e5b9b996b 100644 --- a/tests/pytests/unit/modules/test_transactional_update.py +++ b/tests/pytests/unit/modules/test_transactional_update.py @@ -524,7 +524,7 @@ def test_call_success_explicit_reboot(): with patch.dict(tu.__utils__, utils_mock), patch.dict( tu.__salt__, salt_mock ), patch("salt.modules.transactional_update.reboot", reboot_mock): - tu.call("module.function", key="value") + tu.call("state.sls", key="value") reboot_mock.assert_called_once() @@ -549,7 +549,7 @@ def test_call_success_explicit_reboot_test(): with patch.dict(tu.__utils__, utils_mock), patch.dict( tu.__salt__, salt_mock ), patch("salt.modules.transactional_update.reboot", reboot_mock): - tu.call("module.function", test="True") + tu.call("state.sls", test="True") assert not reboot_mock.called @@ -574,7 +574,7 @@ def test_call_fail_explicit_reboot(): with patch.dict(tu.__utils__, utils_mock), patch.dict( tu.__salt__, salt_mock ), patch("salt.modules.transactional_update.reboot", reboot_mock): - tu.call("module.function", test="True") + tu.call("state.sls", test="True") assert not reboot_mock.called