saltstack / saltstack/salt

[BUG] NetAPI fails when ipc_mode = tcp & cherrypy

Open
#67,808 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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.

https://github.com/saltstack/salt/blob/f906ca5052ed90245538617c14d7f2dbc4b72127/salt/netapi/rest_cherrypy/app.py#L1806-L1880

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.

https://github.com/saltstack/salt/blob/f906ca5052ed90245538617c14d7f2dbc4b72127/salt/netapi/__init__.py#L82-L98

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:

  1. Check that the salt-master is running properly.
    1. 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.
  2. Remove the check. No other endpoint uses the check. It's probably not needed?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.