[BUG] Cannot shut down daemon on FreeBSD if py-setproctitle is installed
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
If py-setproctitle is installed, then commands like service salt_minion status or service salt_minion stop won't work on FreeBSD.
Setup
The bug affects any Salt minion running on FreeBSD, if the py-setproctitle package is also installed. It probably affects the salt master too, though I haven't tested.
- 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
- Install and configure the minion using the FreeBSD package: sysutils/py-salt .
- Start the minion with
service salt_minion start - Attempt to query its status with
service salt_minion status. It will wrongly fail and reportsalt_minion is not running.even though the minion really is running.
Expected behavior
Should see something like this:
salt_minion is running as pid 64436
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Python Version:
Python: 3.11.11 (main, Jan 16 2025, 13:52:49) [Clang 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a
Dependency Versions:
cffi: 1.17.1
cherrypy: Not Installed
cryptography: 42.0.8
dateutil: 2.9.0
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.4
libgit2: Not Installed
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.1.0
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 24.2
pycparser: 2.22
pycrypto: Not Installed
pycryptodome: 3.21.0
pygit2: Not Installed
python-gnupg: Not Installed
PyYAML: 6.0.1
PyZMQ: 25.0.2
relenv: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.5
System Versions:
dist: freebsd 14.2
locale: utf-8
machine: amd64
release: 14.2-AXCIENT1-p1
system: FreeBSD
version: FreeBSD 14.2
Additional context
FreeBSD's service command relies on knowing both a daemon's PID and its process name in order to identify the running daemon. That means the daemon must have a predictable process name. But the salt minion's process name can change, depending on whether py-setproctitle is installed or not. And there are really multiple problems here:
- The process title is unpredictable. It either be
/usr/local/bin/python3.11 /usr/local/bin/salt-minion -c /usr/local/etc/salt --pid-file=/var/run/salt-minion.pid -dorpython3.11: MultiMinionProcessManager MinionProcessManager (python3.11). - When py-setproctitle is installed, the process title has too many spaces (see #67779)
- FreeBSD's
servicecommand expects the process title to be the name of a file, with an optional interpreter. ButMultiMinionProcessManagerisn't a file. Soservicewill print out an annoying warning like/usr/local/etc/rc.d/salt_minion: WARNING: cannot read shebang line from MultiMinionProcessManager, even when I patch Salt to fix the other problems.
Possible Solutions
I see three possible solutions:
- Simply disable setting the process title. It's unnecessary, IMHO.
- Make py-setproctitle into a mandatory dependency and fix the problem of too many spaces.
- On FreeBSD only, don't use
-dand run the process supervised by daemon(8). That would work, but it's an awfully heavyweight solution.
My main question is, why does Salt need to change its process title? Is that really necessary?
Downstream Link
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=285053
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure with the FreeBSD service salt_minion status and stop commands while py-setproctitle is installed. Read the Salt minion process-title handling and the FreeBSD salt_minion service integration; the work is complete when the service reliably identifies the running daemon by PID without the reported process-name warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops, operating-systems
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100