Repository navigation
Description
Description
When calling service.restart salt-minion no_block=True to restart the salt-minion service on a system with systemd, the minion does not manage to send the return before shutting down and throws an exception.
It should be possible to get a return back to the master before the minion finishes shutting down using no_block=True as systemctl return immediately. (Note without no_block=True the process blocks waiting with systemctl waiting for the the minion to exit, which it doesn't because it is waiting for systemctl... but that's another issue).
I suspect it is because the AsyncReqChannel to the master is closed before it receives the return event from the ProcessPayload sub process.
Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)
Please be as specific as possible and give set-up details.
- on-prem machine
- VM (Virtualbox, KVM, etc. please specify)
- VM running on a cloud service, please be explicit and add details
- container (Kubernetes, Docker, containerd, etc. please specify)
- or a combination, please be explicit
- jails if it is FreeBSD
- classic packaging
- onedir packaging
- used bootstrap to install
Steps to Reproduce the behavior
# salt salt-dev1 service.restart salt-minion no_block=True
salt-dev1:
Minion did not return. [No response]
The minions may not have all finished running and any remaining minions will return upon completion. To look up the return data for this job later, run the following command:
salt-run jobs.lookup_jid 20250714111342562766
ERROR: Minions returned with non-zero exit code
# salt-run jobs.lookup_jid 202507141113425627662025-07-14 11:13:42,724 [salt.loaded.int.module.cmdmod:481 ][INFO ][43501] Executing command /usr/bin/systemd-run in directory '/root'
2025-07-14 11:13:42,754 [salt.loaded.int.module.cmdmod:974 ][DEBUG ][43501] stderr: Running as unit: run-r61cd83bc2ece4cb4b2766266ff87fd90.scope; invocation ID: a149b1e649cd4ea392d31fe2ca20762b
2025-07-14 11:13:42,754 [salt.transport.ipc:361 ][DEBUG ][43373] Closing IPCMessageClient instance
2025-07-14 11:13:42,754 [salt.minion :2301][INFO ][43501] Returning information for job: 20250714111342562766
2025-07-14 11:13:42,755 [salt.channel.client:374 ][DEBUG ][43373] Closing AsyncReqChannel instance
2025-07-14 11:13:42,755 [salt.utils.event :312 ][DEBUG ][43501] SaltEvent PUB socket URI: /var/run/salt/minion/minion_event_43fd0ec500_pub.ipc
2025-07-14 11:13:42,755 [salt.utils.event :313 ][DEBUG ][43501] SaltEvent PULL socket URI: /var/run/salt/minion/minion_event_43fd0ec500_pull.ipc
2025-07-14 11:13:42,756 [salt.transport.ipc:361 ][DEBUG ][43373] Closing IPCMessageSubscriber instance
2025-07-14 11:13:42,757 [salt.utils.parsers:1062][WARNING ][43373] Minion received a SIGTERM. Exiting.
2025-07-14 11:13:42,758 [salt.utils.event :823 ][DEBUG ][43501] Sending event: tag = __master_req_channel_payload/231a384f-4af6-4751-ab2a-388cea909b21/127.0.0.1; data = {'cmd': '_return', 'id': 'salt-dev1', 'success': True, 'return': True, 'retcode': 0, 'jid': '20250714111342562766', 'fun': 'service.restart', 'fun_args': ['salt-minion', {'__kwarg__': True, 'no_block': True}], 'user': 'sudo_barney', '_stamp': '2025-07-14T11:13:42.758443'}
2025-07-14 11:13:42,757 [salt.cli.daemons :82 ][INFO ][43373] Shutting down the Salt Minion
2025-07-14 11:14:12,784 [salt.transport.ipc:361 ][DEBUG ][43501] Closing IPCMessageSubscriber instance
2025-07-14 11:14:12,785 [salt.transport.ipc:361 ][DEBUG ][43501] Closing IPCMessageClient instance
2025-07-14 11:14:12,785 [salt.utils.process:1004][ERROR ][43501] An un-handled exception from the multiprocessing process 'ProcessPayload(jid=20250714111342562766)' was caught:
Traceback (most recent call last):
File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/process.py", line 999, in wrapped_run_func
return run_func()
File "/opt/saltstack/salt/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/minion.py", line 1929, in _target
run_func(minion_instance, opts, data)
File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/minion.py", line 1923, in run_func
return Minion._thread_return(minion_instance, opts, data)
File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/minion.py", line 2159, in _thread_return
minion_instance._return_pub(
File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/minion.py", line 2391, in _return_pub
ret_val = self._send_req_sync(load, timeout=timeout)
File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/minion.py", line 1652, in _send_req_sync
raise TimeoutError("Request timed out")
TimeoutError: Request timed outExpected behavior
Job return reaches master before minion processes finish exiting
Screenshots
If applicable, add screenshots to help explain your problem.
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)# salt --versions-report
Salt Version:
Salt: 3006.13
Python Version:
Python: 3.10.17 (main, Jun 9 2025, 20:41:48) [GCC 11.2.0]
Dependency Versions:
cffi: 1.14.6
cherrypy: unknown
cryptography: 42.0.5
dateutil: 2.8.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.6
libgit2: Not Installed
looseversion: 1.0.2
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.2
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 22.0
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.19.1
pygit2: Not Installed
python-gnupg: 0.4.8
PyYAML: 6.0.1
PyZMQ: 23.2.0
relenv: 0.19.3
smmap: Not Installed
timelib: 0.2.4
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: ubuntu 24.04.2 noble
locale: utf-8
machine: x86_64
release: 6.8.0-63-generic
system: Linux
version: Ubuntu 24.04.2 noble
Additional context
On Windows minions, the return reaches the master because win_service.restart actually creates a Windows Scheduler task and executes that, so the return indicates the request for that has succeeded.
Activity
Use KillMode=mixed in salt-minion.service unit
Use KillMode=mixed in salt-minion.service unit
Use KillMode=mixed in salt-minion.service unit