Salt Master Stops Responding
In a 2015.8.0 environment while running commands against the salt-api the following errors are encountered. The error seems to occur randomly without warning. I was not able to find any issues that matched this behavior exactly, but have seen a few describing similar issues. (with windows minions. This environment is entirely Linux.) The master is: Linux cm15virtual 3.10.0-229.el7.x86_64 #1 SMP Thu Jan 29 18:37:38 EST 2015 x86_64 x86_64 x86_64 GNU/Linux
My understanding of what is happening from the master log (included below) is that the master stops responding to the minion for some reason (there are plenty of worker_threads for the given environment).
Any help with is would be appreciated. Thanks!
The following is from the salt master log:
2016-01-12 14:17:45,174 [salt.loaded.int.netapi.rest_cherrypy.app][DEBUG ][2507] Error while processing request for: /
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/netapi/rest_cherrypy/app.py", line 507, in hypermedia_handler
ret = cherrypy.serving.request._hypermedia_inner_handler(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/cherrypy/_cpdispatch.py", line 34, in __call__
return self.callable(*self.args, **self.kwargs)
File "/usr/lib/python2.7/site-packages/salt/netapi/rest_cherrypy/app.py", line 929, in POST
token=cherrypy.session.get('token')))
File "/usr/lib/python2.7/site-packages/salt/netapi/rest_cherrypy/app.py", line 771, in exec_lowstate
ret = self.api.run(chunk)
File "/usr/lib/python2.7/site-packages/salt/netapi/__init__.py", line 66, in run
return l_fun(*f_call.get('args', ()), **f_call.get('kwargs', {}))
File "/usr/lib/python2.7/site-packages/salt/netapi/__init__.py", line 77, in local_async
return local.run_job(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 297, in run_job
raise SaltClientError(general_exception)
SaltClientError: Salt request timed out. The master is not responding. If this error persists after verifying the master is up, worker_threads may need to be increased.
2016-01-12 14:17:47,268 [cherrypy.access.58650000][INFO ][2507] 127.0.0.1 - - [12/Jan/2016:14:17:47] "POST / HTTP/1.1" 500 1277 "" "Java/1.8.0_65"
2016-01-12 14:17:45,600 [salt.loaded.int.netapi.rest_cherrypy.app][DEBUG ][2507] Error while processing request for: /
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/salt/netapi/rest_cherrypy/app.py", line 507, in hypermedia_handler
ret = cherrypy.serving.request._hypermedia_inner_handler(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/cherrypy/_cpdispatch.py", line 34, in __call__
return self.callable(*self.args, **self.kwargs)
File "/usr/lib/python2.7/site-packages/salt/netapi/rest_cherrypy/app.py", line 929, in POST
token=cherrypy.session.get('token')))
File "/usr/lib/python2.7/site-packages/salt/netapi/rest_cherrypy/app.py", line 771, in exec_lowstate
ret = self.api.run(chunk)
File "/usr/lib/python2.7/site-packages/salt/netapi/__init__.py", line 66, in run
return l_fun(*f_call.get('args', ()), **f_call.get('kwargs', {}))
File "/usr/lib/python2.7/site-packages/salt/netapi/__init__.py", line 77, in local_async
return local.run_job(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 297, in run_job
raise SaltClientError(general_exception)
SaltClientError: Salt request timed out. The master is not responding. If this error persists after verifying the master is up, worker_threads may need to be increased.
2016-01-12 14:17:47,270 [cherrypy.access.58650000][INFO ][2507] 127.0.0.1 - - [12/Jan/2016:14:17:47] "POST / HTTP/1.1" 500 1277 "" "Java/1.8.0_65"
@nbow, thanks for the report. Is it possible for you to provide more information, such as the master and api configs and the full request and response you're seeing/using? Can you interact with the salt master after/when this happens? Does it lose contact with the minion in this context?
api config:
log_level: debug
rest_cherrypy:
port: 9999
disable_ssl: True
expire_responses : False
debug: True
external_auth:
pam:
username:
- .*
- '@wheel'
- '@runner'
state_output: changes
state_verbose: False
master config:
file_roots:
base:
- /opt/salt
- /install
extension_modules: /opt/python
ext_pillar:
- jsonPillar: /opt/pillar
worker_threads: 50
The master does not appear to stop being able to be interacted with. However, it is difficult to tell because it happens so quickly and without warning. This also means that it happens with different commands being sent to the master via the api. The master can be interacted with after this happens, and responds without any issues.
It is not known if the minion truly looses contact with the master in the environment. It is able to receive and send commands after this happens.
Also there are 13 minions in the environment.
@nbow, thanks for the extra information. Can you post the request and response you're using with salt-api or describe more specifically what commands you're sending through salt-api? Thanks.
I'm not able to provide the exact api commands since it randomly happens with different commands. After doing some additional configuration changes in the environment, I have some questions about how the master worker_threads should be configured. The environment originally had 20 worker_threads for 13 minions on a 2 core 4GB RAM box. This was increased to 50 worker_threads, which seamed to stabilize things. However, there was still a 500 error as described above encountered. The box was then upgraded to a 4 core 8GB RAM box. There hasn't been any 500 issues seen since this change. My question is: Is there documentation somewhere that helps one determine how may worker_threads and how big of a box is needed for a SaltStack Master? I haven't seen any in my searching, just a section describing what the worker_treads are. Also, does it seam likely that the above error is actually caused by the "lack of resources", or does it seam more likely that the intermittence of the error is disguising a larger issue.
@nbow, there is also this documentation, although it does not address worker_threads specifically. 50 worker thread should be plenty for way more than 13 minions. You might also want to watch @jacksontj discuss issues related to this topic.
After some additional configuration changes in the environment and some stress testing, it looks like the issue was mitigated. I'm still not sure if this is a code issue or a configuration issue, however. Thank you for the links to the documentation, it helped. Would it be possible for constant checking of the job status through the rest-api to cause a issue? Also, what are the differences between polling the rest-api for event data vs monitoring the bus directly?
@nbow, I am not sure. @whiteinge may be able to give you a better answer than I.
Would it be possible for constant checking of the job status through the rest-api to cause a issue?
I wouldn't rule it out as a possibility but I'm not aware of any current bugs in that regard. We have also seen thread-safe issues with ZeroMQ in the past. salt-api doesn't use ZeroMQ but Salt's Python API does so there may be an error in how we're calling into Salt. It's often difficult to separate salt-api errors from Salt errors since Salt stacktraces will be surrounded by the salt-api wrapper code.
Barrage of troubleshootings questions to follow -- sorry for the bulk, with so many unknowns I'm trying to cover a lot of bases.
- How many concurrent connections would you estimate you had to rest_cherrypy at any given point?
- How long would any given connection usually stay connected to rest_cherrypy?
- What Salt clients and functions would you typically be calling repeatedly?
- Only the jobs Runner?
- A combination of the jobs runner and also running regular Salt commands?
- Are you using
external_job_cacheormaster_job_cache?
- Do you happen to see the error
Bad file descriptororBad file descriptor (src/kqueue.cpp:[...])orProcess <function start [...] died with exit status None, restarting...buried somewhere in your logs or terminal scrollback when the error occurs? (Ellipsis added for system-specific data. Look for the general pattern.)
Also, what are the differences between polling the rest-api for event data vs monitoring the bus directly?
The /events URL in rest_cherrypy is written specifically for long-running connections. It's fairly lightweight: it starts listening to Salt's event bus and formats the events as JSON. You need to start listening before you fire any jobs you care about but it's definitely the preferred way to go.
Polling the /jobs endpoint (which calls the jobs runner) or polling / and calling the jobs runner yourself is fairly heavy. Starting the runner itself is a tad slow: it reads the Salt configs, starts up it's own event listener, hits the file system to look for job returns (or the remote data store if external), and fires its own events with the result. In addition to that, if you have lots of stored jobs returns the disk IO to produce that report over and over is noticeable.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.