Skip to content

Salt Master Hang #29674

Closed
Closed

Description

@jakehilton

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

  1. jakehilton commented on Dec 14, 2015

    @jakehilton
    Author

    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

    # salt-run manage.down removekeys=True
    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.
    

    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.

  2. added
    Core
    severity-high
    P3
    bug
    pending-discussion
    on Dec 15, 2015
  3. added this to the Under Review milestone on Dec 15, 2015
  4. jfindlay commented on Dec 15, 2015

    @jfindlay
    Contributor

    @jakehilton, thanks for the report. @meggiebot, @cachedout, do you have any ideas here?

  5. Ch3LL commented on Dec 15, 2015

    @Ch3LL
    Contributor

    @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-key and 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?

  6. jakehilton commented on Dec 15, 2015

    @jakehilton
    Author

    Thank you for looking into this issue.

    My master config looks like so on both masters:

    open_mode: True
    top_file_merging_strategy: same
    
    file_roots:
      base:
        - /etc/salt/git/salt
    
    pillar_roots:
      base:
        - /etc/salt/git/salt/pillar
    
    worker_threads: 30
    timeout: 30
    

    My minion config looks like so:

    random_reauth_delay: 60
    recon_default: 1000
    recon_max: 5000
    recon_randomize: True
    keysize: 2048
    startup_states: highstate
    master:
      - smaster1.server.com
      - smaster2.server.com
    grains:
      salt_setup: true
      ultype: smaster
      ulsite: uplynk
    id: ause1-encoder646
    

    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.

    # salt-key | grep 646
    ause1-encoder646
    

    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!

  7. Ch3LL commented on Dec 16, 2015

    @Ch3LL
    Contributor

    @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_minion command 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.

  8. jakehilton commented on Dec 16, 2015

    @jakehilton
    Author

    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

    schedule:
      highstate:
        function: state.highstate
        minutes: 60
        maxrunning: 1
    

    My problematic schedule yaml looked like this:

    schedule:
      highstate:
        function: cmd.run
        minutes: 30
        args:
          - 'salt-call -l warning --log-file-level=warning state.highstate'
        kwargs:
          stateful: False
          shell: /bin/sh
    
      minion_cleanup:
        function: cmd.run
        minutes: 30
        args:
          - 'salt --out txt "*" test.ping | grep "Not connected" | cut -d ":" -f 1 | xargs -I dead_minion salt-key -y -d dead_minion'
        kwargs:
          stateful: False
          shell: /bin/sh
    

    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.

  9. Ch3LL commented on Dec 17, 2015

    @Ch3LL
    Contributor

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

  10. jakehilton commented on Dec 18, 2015

    @jakehilton
    Author

    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.

  11. jakehilton commented on Dec 18, 2015

    @jakehilton
    Author

    I just had two masters hung.. with a lot of these messages before the freeze:

    2015-12-16 18:45:59,229 [salt.transport.zeromq][ERROR   ][10409] Bad load from minion
    2015-12-16 18:45:59,230 [salt.transport.zeromq][ERROR   ][10471] Bad load from minion
    2015-12-16 18:45:59,350 [salt.transport.zeromq][ERROR   ][10409] Bad load from minion
    2015-12-16 18:45:59,504 [salt.transport.zeromq][ERROR   ][10442] Bad load from minion
    

    That happened on one of the two multi-masters.. nothing else in the logs then just a ton of those.

  12. 42 remaining items

  13. removed this from the B 1 milestone on Mar 10, 2016
  14. modified the milestones: B -2, B -1 on Apr 11, 2016
  15. modified the milestones: B -3, B -2 on Apr 25, 2016
  16. modified the milestones: C 10, B -3 on May 9, 2016
  17. DmitryKuzmenko commented on May 11, 2016

    @DmitryKuzmenko
    Contributor

    I've reproduced something looking close to this:

    1. Setup multimaster environment with 2 masters and 1 minion.
    2. Setup shceduler: alive every 30 seconds, state.apply every 20 seconds
    3. Run all and check test.ping works from both masters.
    4. Delete the minion key on all masters with salt-key -y -D
    5. Run minion again.

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

  18. DmitryKuzmenko commented on May 13, 2016

    @DmitryKuzmenko
    Contributor

    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.

  19. jakehilton commented on May 13, 2016

    @jakehilton
    Author

    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=True command 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.

  20. DmitryKuzmenko commented on May 16, 2016

    @DmitryKuzmenko
    Contributor

    @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!

  21. added
    fixed-pls-verify
    and removed
    pending-discussion
    on May 18, 2016
  22. cachedout commented on May 23, 2016

    @cachedout
    Contributor

    This has been resolved by #33333

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

CoreP3bugfixed-pls-verifyseverity-high

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions