Repository navigation
Description
I've got 8 salt masters running in pairs for redundancy. So 4 groups handling roughly 500-600 servers each. Every few days the masters will hang. They both hang at the same time and requires a restart to help clear things up.
I have the minions run a highstate every 30 min. If I used the documented highstate schedule (https://docs.saltstack.com/en/latest/topics/jobs/schedule.html#highstates) things would blow up so I'm using a simple schedule cmd.run. I'm also running a cleanup script from the masters every 30 minutes to clean out stale minions.
The command I'm running to clear out stale minions is:
salt --out txt "*" test.ping | grep "Not connected" | cut -d ":" -f 1 | xargs -I dead_minion salt-key -y -d dead_minion
I did test out salt-run manage.down removekeys=True but it didn't seem to work as well.
I'm not seeing any issues with minions being removed per se.. but I am seeing salt master hanging. So when new boxes come online they aren't provisioned properly.
I"m seeing errors in the that seem to suggest that an internal minion check is failing miserably. The log is below.
A log section:
2015-12-13 06:53:53,199 [salt.master ][ERROR ][17378] Error in function _mine:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1379, in run_func
ret = getattr(self, func)(load)
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1007, in _mine
load = self.__verify_load(load, ('id', 'data', 'tok'))
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 924, in __verify_load
if not self.__verify_minion(load['id'], load['tok']):
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 824, in __verify_minion
with salt.utils.fopen(pub_path, 'r') as fp_:
File "/usr/lib/python2.7/dist-packages/salt/utils/__init__.py", line 1204, in fopen
fhandle = open(*args, **kwargs)
IOError: [Errno 2] No such file or directory: '/etc/salt/pki/master/minions/ause1-encoder546'
2015-12-13 06:54:25,104 [salt.transport.zeromq][ERROR ][17378] Bad load from minion
2015-12-13 06:54:35,228 [salt.transport.zeromq][ERROR ][17370] Bad load from minion
2015-12-13 06:54:46,744 [salt.transport.zeromq][ERROR ][17398] Bad load from minion
2015-12-13 06:54:53,352 [salt.master ][ERROR ][17317] Error in function _mine:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1379, in run_func
ret = getattr(self, func)(load)
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1007, in _mine
load = self.__verify_load(load, ('id', 'data', 'tok'))
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 924, in __verify_load
if not self.__verify_minion(load['id'], load['tok']):
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 824, in __verify_minion
with salt.utils.fopen(pub_path, 'r') as fp_:
File "/usr/lib/python2.7/dist-packages/salt/utils/__init__.py", line 1204, in fopen
fhandle = open(*args, **kwargs)
IOError: [Errno 2] No such file or directory: '/etc/salt/pki/master/minions/ause1-encoder546'
2015-12-13 06:55:00,814 [salt.master ][ERROR ][17343] Error in function _mine:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1379, in run_func
ret = getattr(self, func)(load)
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1007, in _mine
load = self.__verify_load(load, ('id', 'data', 'tok'))
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 924, in __verify_load
if not self.__verify_minion(load['id'], load['tok']):
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 824, in __verify_minion
with salt.utils.fopen(pub_path, 'r') as fp_:
File "/usr/lib/python2.7/dist-packages/salt/utils/__init__.py", line 1204, in fopen
fhandle = open(*args, **kwargs)
IOError: [Errno 2] No such file or directory: '/etc/salt/pki/master/minions/ause1-encoder646'
2015-12-13 06:55:17,444 [salt.master ][ERROR ][17443] Error in function _mine:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1379, in run_func
ret = getattr(self, func)(load)
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1007, in _mine
load = self.__verify_load(load, ('id', 'data', 'tok'))
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 924, in __verify_load
if not self.__verify_minion(load['id'], load['tok']):
File "/usr/lib/python2.7/dist-packages/salt/master.py", line 824, in __verify_minion
with salt.utils.fopen(pub_path, 'r') as fp_:
File "/usr/lib/python2.7/dist-packages/salt/utils/__init__.py", line 1204, in fopen
fhandle = open(*args, **kwargs)
IOError: [Errno 2] No such file or directory: '/etc/salt/pki/master/minions/ause1-encoder66'
I'm also seeing endless logs about the "bad load from minion" even after I ping out to all the minions.
The multi-master setup I'm using is:
https://docs.saltstack.com/en/latest/topics/tutorials/multimaster.html
Would this be better?
https://docs.saltstack.com/en/latest/topics/tutorials/multimaster_pki.html
Ideally having two hot is great but if it causes issues then obviously I'll back off of it.
Any help in determining the core issue would be much appreciated.
Thanks!
Activity
jakehilton commentedon Dec 14, 2015
I forgot to mention I'm running the latest salt.. 2015.8.3 on ubuntu 14.04.3
A little more information about minion removing as well.. For instance.. on one box with 561 minions I just tried
I've got my workers at 20 right now on that box.
On it's sister box with 50 worker threads configured I get the same error.
jfindlay commentedon Dec 15, 2015
@jakehilton, thanks for the report. @meggiebot, @cachedout, do you have any ideas here?
Ch3LL commentedon Dec 15, 2015
@jakehilton can you please post any related multi- master configurations, particularly the minion configuration file. I want to attempt to try to recreate this issue but want to ensure I have the same multi-master settings. Also is there any other related information in the debug logs when the master hangs?
In your logs it keeps stating it does not see the key for the 'ause1-encoder646' minion. Can you run
salt-keyand see if its in your list of minions please.Also I found this issue: #15471 Are you using salt-call anywhere while the salt-minion process is not running?
jakehilton commentedon Dec 15, 2015
Thank you for looking into this issue.
My master config looks like so on both masters:
My minion config looks like so:
There was really only that cleanup call that ran on a schedule that I think is causing the issue. What is strange is that it's trying to reference a minion file that is gone.. and it seemingly blows up because of that.
I do show that the minion is still listed.
It does list quite a few minion files.. I didn't send the whole log because it repeated the error for quite a few minions.
Thanks for your help in this!
Ch3LL commentedon Dec 16, 2015
@jakehilton I have setup the following:
2 masters with the same configurations as yours
1 minion with same configurations as yours
I understand this is not the exact scenario as yours but suspect I should be able to recreate the same thing. I have tried running the
salt --out txt "*" test.ping | grep "Not connected" | cut -d ":" -f 1 | xargs -I dead_minion salt-key -y -d dead_minioncommand and have not been able to recreate your issue.My other thought is the state.highstate schedule you have setup. Can you post your scheduler configurations for both the salt-key -d command and the highstate so I can try to exactly replicate your scenario.
My other suggestion would be to remove one of these out at a time to see if either the highstate or the salt-key delete commands are causing this behvaior.
I will keep monitoring the servers today and see if I might see the salt-masters hang at a later time.
jakehilton commentedon Dec 16, 2015
It did take a few days for the hang to occur. It was when I had both schedules running in concert.
Since removing the schedule to clear out dead minions the salt masters seem to have stabilized. I'm continuing to monitor it now.
My current schedule yaml looks like this
My problematic schedule yaml looked like this:
You may also need to have a lot of minions coming and going to reproduce this issue.. seeing as we have some churn with minions. Not sure if you'll see it without some level of turn over.
Ch3LL commentedon Dec 17, 2015
@jakehilton okay i've setup the schedules with 3 minions and i'll take one minion out of the picture to test this. I'll wait a day or two to see if the master is hanging.
I just re-read your earlier response when you stated that you could see the key of the minion that was in error in the log when running salt-key. Is it an accepted minion? Is this minion suppose to be a deleted key?
are your salt-masters still stabilized since removing the schedule to remove the keys? I'm curious if the problem is related to these jobs running at the same time. I'm not entirely sure though and I am guessing someone else would have some more insight to why this might be occurring.
@cachedout do you have any ideas as to why this is occuring?
In the meantime I will continue to see if i can recreate this issue and post my results probably in the next couple of days, since you stated it takes a few days for the master to hang.
jakehilton commentedon Dec 18, 2015
You may need to introduce some minion churn.. minions coming and going. Not sure if that's possible with your test setup.
We use an open master so all keys are accepted automatically. The script is supposed to cleanup minion connections that are stale. So it wasn't a deleted key when this script ran I believe.
So far the salt masters have not exhibited the hang after removing that call to cleanup stale minions. I am going to do a full test on all the masters this morning to make sure everything is still happy.
Thank you.
jakehilton commentedon Dec 18, 2015
I just had two masters hung.. with a lot of these messages before the freeze:
That happened on one of the two multi-masters.. nothing else in the logs then just a ton of those.
42 remaining items
DmitryKuzmenko commentedon May 11, 2016
I've reproduced something looking close to this:
test.pingworks from both masters.salt-key -y -DAfter that either one or both masters don't respond to minion request and salt commands.
There are no any exception or error in master logs.
I'm continuing to investigate this.
DmitryKuzmenko commentedon May 13, 2016
Caught it!
The problem I've found: if a minion's key was removed and the minion still think it's connected and perform interactions with the master, master handles requests and tries to respond but throws IOException in worker when trying to encrypt a response for minion because there's no minion key anymore. The exception doesn't appear in the log that is the reason it looked so magic.
It appears in salt/transport/zeromq.py:587 in handle_message in send_private case.
Why it hangs: master worker uses zmq router-dealer patter with multiple REP workers connected to the dealer. When the exception occurs the worker didn't sent a reply that means REP socket will not handle any incoming messages.
Solution (not implemented yet): surely first we have to handle the exception. Also I think good idea would be to send some signal to the minion that would force it's reconnection to the failed master.
jakehilton commentedon May 13, 2016
So would this manifest with the TCP transport as well? It doesn't use the zmq libraries correct? I don't seem to experience it when using the TCP transport hence my question.
We run a
salt-run manage.down removekeys=Truecommand periodically from the masters so if when they are run the minion doesn't respond they are removed.. and then if the minion still thinks they are connected it could fall into the scenario you explained if using zmq transport.Great to see progress on this! Thanks for your help.
DmitryKuzmenko commentedon May 16, 2016
@jakehilton for TCP transport there is the same case but it wouldn't fall to the same issue, i.e. master will not hang because TCP transport doesn't follow REP pattern in the master worker. So it's not require each message to be replied. But TCP transport need to be updated too to properly handle the case.
Thank you for good catch @jakehilton!
cachedout commentedon May 23, 2016
This has been resolved by #33333