[BUG] NetAPI fails when ipc_mode = tcp & cherrypy
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
The netapi does a naive check for if the salt-master is running before processing any requests. This check is fundamentally broken when ipc_mode = tcp.
Setup
- Configure "ipc_mode: tcp" in the master config.
- Start the API server.
- Attempt to login / run commands.
- Can't.
The cherrypy login endpoint does a check to see if the salt-master is running. Overall it seems pretty reasonable to do so.
That check is fundamentally flawed. It is only checking if some IPC socket files exist. And it's not even checking if they're socket files (but that's beside the point)! These socket files do not exist when ipc_mode = tcp. If I create the files the salt-api endpoint works with no further issues.
For what it's worth the cherrypy login endpoint is the ONLY endpoint that checks if the salt-master is running. The tornado server does no checks whatsoever.
Options to fix:
- Check that the salt-master is running properly.
- Might be worth extending the checks to all the places that it's not checked or do one global check when the api starts and if it the salt-master is not running exit and if it is assume it's always running.
- Remove the check. No other endpoint uses the check. It's probably not needed?
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
Reproduce the setup with ipc_mode: tcp, then inspect the login check in salt/netapi/rest_cherrypy/app.py around lines 1806-1880 and the socket handling in salt/netapi/__init__.py around lines 82-98. Determine whether the check should be removed or replaced, and verify that the CherryPy login endpoint works with TCP IPC without manually creating socket files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100