Skip to content

[Bug]: salt-minion processes don't stop when managed by systemctl #68406

Closed

Description

@ldav1s

What happened?

I attempted a sudo systemctl restart salt-minion (which will stop and start salt-minion) on a subset of the minions registered with that salt master. That command returned without error. I then attempted a test.ping from the master which timed out on a few minions in that subset. That subset of minions are all physical hosts.

So I logged into one of the failing minions:

$ sudo systemctl status salt-minion.service 
● salt-minion.service - The Salt Minion
     Loaded: loaded (/lib/systemd/system/salt-minion.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2025-10-15 19:40:05 UTC; 41min ago
       Docs: man:salt-minion(1)
             file:///usr/share/doc/salt/html/contents.html
             https://docs.saltproject.io/en/latest/contents.html
    Process: 81226 ExecStart=/usr/bin/salt-minion (code=exited, status=1/FAILURE)
   Main PID: 81226 (code=exited, status=1/FAILURE)
      Tasks: 7 (limit: 309126)
     Memory: 450.8M
     CGroup: /system.slice/salt-minion.service
             ├─  66658 /opt/saltstack/salt/bin/python3.10 /usr/bin/salt-minion MultiMinionProcessManager MinionProcessManager ProcessPayload(jid=20251015190818334152) Minion._thread_return
             └─1079760 /opt/saltstack/salt/bin/python3.10 /usr/bin/salt-minion MultiMinionProcessManager MinionProcessManager

According to ps aux process 1079760 was from the time I installed 3006.16 on this minion or later that same day:

$ ps aux | grep salt
root       66658  0.5  0.0 818072 147684 ?       Sl   19:08   0:25 /opt/saltstack/salt/bin/python3.10 /usr/bin/salt-minion MultiMinionProcessManager MinionProcessManager ProcessPayload(jid=20251015190818334152) Minion._thread_return
ldavis    109652  0.0  0.0  12252  2132 pts/0    S+   20:22   0:00 grep --color=auto salt
root     1079760  0.2  0.0 754980 94736 ?        S    Sep26  66:57 /opt/saltstack/salt/bin/python3.10 /usr/bin/salt-minion MultiMinionProcessManager MinionProcessManager

As part of the job I use to install the salt-minion onedir packages, I do attempt to restart the service post-install shortly after the install completes. I tended to get less unstarted minions that way in the past (and currently).

After killing the old process and restarting salt-minion:

$ sudo kill -9 1079760
$ sudo systemctl restart salt-minion.service

I was able to test.ping from the minion's salt master again and receive a response.

I then invoked sudo systemctl stop salt-minion on the previous subset of minions. When I searched for salt-minion processes on this subset, many had correctly shutdown all of them, but a few still had lingering Minion._thread_return processes, which I kill -9ed before invoking sudo systemctl start salt-minion on them to restart salt-minion.

I noticed in /lib/systemd/system/salt-minion.service that the kill mode is set to process

...
[Service]
KillMode=process
...

instead of the default control-group.

I was requested to open a new issue for 3006.16 here:

Originally posted by @barneysowood in #65265

I cannot choose the correct OS version; apparently Ubuntu 20.04 has been removed.

Type of salt install

Official deb

Major version

3006.x

What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)

ubuntu-22.04

salt --versions-report output

$ salt --versions-report
Salt Version:
          Salt: 3006.16
 
Python Version:
        Python: 3.10.18 (main, Sep  5 2025, 22:48:51) [GCC 11.2.0]
 
Dependency Versions:
          cffi: 1.17.1
      cherrypy: 18.10.0
  cryptography: 42.0.5
      dateutil: 2.8.1
     docker-py: Not Installed
         gitdb: 4.0.10
     gitpython: Not Installed
        Jinja2: 3.1.6
       libgit2: 1.9.1
  looseversion: 1.0.2
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 24.0
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: 1.18.2
  python-gnupg: 0.4.8
        PyYAML: 6.0.1
         PyZMQ: 23.2.0
        relenv: 0.20.6
         smmap: 5.0.0
       timelib: 0.3.0
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: ubuntu 20.04.6 focal
        locale: utf-8
       machine: x86_64
       release: 5.4.0-216-generic
        system: Linux
       version: Ubuntu 20.04.6 focal

$ salt-minion --versions-report
Salt Version:
          Salt: 3006.16
 
Python Version:
        Python: 3.10.18 (main, Sep  5 2025, 22:48:51) [GCC 11.2.0]
 
Dependency Versions:
          cffi: 1.14.6
      cherrypy: 18.10.0
  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: 24.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.20.6
         smmap: Not Installed
       timelib: 0.3.0
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: ubuntu 20.04.2 focal
        locale: utf-8
       machine: x86_64
       release: 5.4.0-26-generic
        system: Linux
       version: Ubuntu 20.04.2 focal

Activity

  1. added
    bug
    on Oct 16, 2025
  2. welcome commented on Oct 16, 2025

    @welcome

    Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here's some information that may help as you continue your Salt journey.
    Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

    There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
    If you have additional questions, email us at [email protected]. We're glad you've joined our community and look forward to doing awesome things with you!

  3. self-assigned this
    on Oct 17, 2025
  4. OrangeDog commented on Oct 19, 2025

    @OrangeDog
    Contributor

    Comments in #33665 imply that there's some reason for it, but I can't see why.
    Systemd specifically advises against it:

    Note that it is not recommended to set KillMode= to process or even none, as this allows processes to escape the service manager's lifecycle and resource management, and to remain running even while their service is considered stopped and is assumed to not consume any resources.

    Personally, I have overridden it to mixed.

  5. twangboy commented on Oct 30, 2025

    @twangboy
    Contributor

    Going through the history I found the reason here:
    #33792 (comment)

    There's a long-running issue of Salt being able to update itself. KillMode=process allows a child process to continue upgrading salt-minion even though the parent process has been killed by the upgrade process.

    The discussion in the above issue was more about why that setting was applied to other salt services (master, api, etc). It was determined that it was only needed by the minion to upgrade itself.

  6. ldav1s commented on Oct 30, 2025

    @ldav1s
    ContributorAuthor

    I'll have to admit that I've never used the salt builtins for this e.g. saltutil.update (which might be platform specific).

    This is the method I use, which I alluded to in my original report:

    sudo salt '<targets>' cmd.run 'apt update'
    sudo salt '<targets>' cmd.run 'echo "sleep 10; DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::=--force-confold salt-minion; sleep 30; systemctl restart salt-minion.service" | at -M <time>'
    

    But because KillMode=process stale processes from the previous salt-minion still hang around.

    It seems that the historical problem is that the regular KillMode kills salt-minion before the .deb is fully deployed, resulting in a broken package. It might be possible to move the running salt-minion processes to another cgroup prior to the package deploy so that KillMode kills nothing (the old processes are in a different cgroup at this point), the deploy completes, and something on start of salt-minion kills the cgroup containing the previous salt-minion processes.

  7. barneysowood commented on Nov 12, 2025

    @barneysowood
    Collaborator

    I wouldn't want to change to KillMode=control-group as this would break my recent fix to allow service.restart salt-minion to work (see #68183 and #68209) as it sends a SIGTERM to all processes in the cgroup and leads to the process trying to send the return being terminated too soon.

    Some brief testing with KillMode=mixed looks positive - that only sends the SIGTERM to the main process but will cleanup any remaining processes in the cgroup with a SIGKILL once the main process exits or after TimeoutStopSec (90s), so allows the return to happen but should be much better at cleaning up any leftover processes.

    I'd like to do a bit more testing to make sure that works reliably.

    WRT to the issue of salt being able to update itself, where systemd was killing the package upgrade, I'm not sure if that is an issue any more - both aptpkg and yumpkg run sub-processes in a separate systemd scope. I'll do a bit of testing, but if anyone can give an instance of when that is an issue, that'd be good.

    @ldav1s - WRT to saltutil.update, I've never spotted that before.. I suspect it's an artefact of some ancient packaging system:

    This feature requires the minion to be running a bdist_esky build
    

    I suspect it could be removed and I may take a look at that..

    I've also been thinking about building something by way of a runner that will give a standardised way to do minion upgrades... everyone has their own way of doing it that works for them but everyone is re-inventing the wheel and it'd be better to have a standard way we can all improve.

  8. barneysowood commented on Nov 12, 2025

    @barneysowood
    Collaborator

    WRT to the issue of salt being able to update itself, where systemd was killing the package upgrade, I'm not sure if that is an issue any more - both aptpkg and yumpkg run sub-processes in a separate systemd scope. I'll do a bit of testing, but if anyone can give an instance of when that is an issue, that'd be good.

    Doing a salt <minion> pkg.upgrade with available salt packages (on Ubuntu 24.04), the package gets upgraded. Unfortunately the restart initiated by apt fails - the MinionManager process and the process handling the return don't get killed.. although they seem to die shortly after, although by that time systemd has given up. This then requires a start of the salt-minion service.

    Tried the same with an override to set KillMode=mixed and although the restart has to fall back to sending SIGKILL, it does clean up the child processes and the service successfully restarts. So that's looking promising.

  9. OrangeDog commented on Nov 13, 2025

    @OrangeDog
    Contributor

    Exactly. This hack to get it to work properly is actually the cause of it not working properly in the first place.

  10. ldav1s commented on Nov 13, 2025

    @ldav1s
    ContributorAuthor

    It might not be possible to set one KillMode for all the ways that users want to start/restart salt-minion. For example:

    • systemctl restart salt-minion.service
    • salt pkg.upgrade
    • salt service.restart salt-minion

    etc. I'll have to take a look at KillMode=mixed.

  11. added this to the Sulphur v3006.26 milestone on Jun 7, 2026
  12. added 4 commits that reference this issue on Jun 12, 2026
    cff93d5
    38220cd
    194f930
    d128283
  13. added a commit that references this issue on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions