Skip to content

Minion failover only works once #30181

Closed
Closed

Description

@jakehilton

When a failover is detected by a minion it correctly fails over to the second master in the list. If the original master is fixed and then the secondary master is taken down the minion does not connect back to the original master.

As mentioned here: https://docs.saltstack.com/en/latest/topics/highavailability/index.html
" If the master does not respond, the minion will attempt to connect to the next master in the list. If the minion runs out of masters, the list will be recycled in case dead masters have been restored."

This does not seem to be happening. It detects the first master server dying.. but after that it does not.

Minion config:

master:
  - smaster2-dusw.xxxx.com
  - smaster1-dusw.xxxx.com
master_type: failover
master_alive_interval: 10
retry_dns: 0

The debug logs show that it has other errors and timeouts.. but doesn't properly detect the failed master

[DEBUG   ] schedule.handle_func: Incrementing jobcount, now 2, maxrunning is 2
[DEBUG   ] schedule.handle_func: The scheduled job __master_alive was not started, 2 already running
[DEBUG   ] Handling event '_minion_mine\n\n\x85\xa5clear\xc2\xa3cmd\xa5_mine\xa4data\x80\xa2id\xafdusw1-content17\xa6_stamp\xba2016-01-06T19:05:06.160415'
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'dusw1-content17', 'tcp://172.31.47.127:4506', 'aes')
[DEBUG   ] Initializing new SAuth for ('/etc/salt/pki/minion', 'dusw1-content17', 'tcp://172.31.47.127:4506')
[DEBUG   ] SaltReqTimeoutError, retrying. (1/3)
[DEBUG   ] SaltReqTimeoutError, retrying. (1/3)
[DEBUG   ] SaltReqTimeoutError, retrying. (1/3)
[DEBUG   ] SaltReqTimeoutError, retrying. (2/3)
[DEBUG   ] SaltReqTimeoutError, retrying. (2/3)
[DEBUG   ] SaltReqTimeoutError, retrying. (2/3)
[DEBUG   ] SaltReqTimeoutError, retrying. (3/3)
[DEBUG   ] SaltReqTimeoutError, retrying. (3/3)
[DEBUG   ] SaltReqTimeoutError, retrying. (3/3)
[ERROR   ] Unhandled exception running status.master
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/utils/schedule.py", line 710, in handle_func
    channel.send(load)
  File "/usr/lib/python2.7/dist-packages/salt/utils/async.py", line 73, in wrap
    ret = self._block_future(ret)
  File "/usr/lib/python2.7/dist-packages/salt/utils/async.py", line 83, in _block_future
    return future.result()
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 876, in run
    yielded = self.gen.throw(*exc_info)
  File "/usr/lib/python2.7/dist-packages/salt/transport/zeromq.py", line 231, in send
    ret = yield self._crypted_transfer(load, tries=tries, timeout=timeout)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 870, in run
    value = future.result()
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 876, in run
    yielded = self.gen.throw(*exc_info)
  File "/usr/lib/python2.7/dist-packages/salt/transport/zeromq.py", line 199, in _crypted_transfer
    ret = yield _do_transfer()
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 870, in run
    value = future.result()
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 876, in run
    yielded = self.gen.throw(*exc_info)
  File "/usr/lib/python2.7/dist-packages/salt/transport/zeromq.py", line 185, in _do_transfer
    tries=tries,
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 870, in run
    value = future.result()
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
SaltReqTimeoutError: Message timed out
[DEBUG   ] schedule.handle_func: Removing /var/cache/salt/minion/proc/20160106190435406223
[ERROR   ] Unhandled exception running status.master
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/utils/schedule.py", line 710, in handle_func
    channel.send(load)
  File "/usr/lib/python2.7/dist-packages/salt/utils/async.py", line 73, in wrap
    ret = self._block_future(ret)
  File "/usr/lib/python2.7/dist-packages/salt/utils/async.py", line 83, in _block_future
    return future.result()
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 876, in run
    yielded = self.gen.throw(*exc_info)
  File "/usr/lib/python2.7/dist-packages/salt/transport/zeromq.py", line 231, in send
    ret = yield self._crypted_transfer(load, tries=tries, timeout=timeout)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 870, in run
    value = future.result()
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 876, in run
    yielded = self.gen.throw(*exc_info)
  File "/usr/lib/python2.7/dist-packages/salt/transport/zeromq.py", line 199, in _crypted_transfer
    ret = yield _do_transfer()
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 870, in run
    value = future.result()
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 876, in run
    yielded = self.gen.throw(*exc_info)
  File "/usr/lib/python2.7/dist-packages/salt/transport/zeromq.py", line 185, in _do_transfer
    tries=tries,
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 870, in run
    value = future.result()
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
SaltReqTimeoutError: Message timed out
[DEBUG   ] schedule.handle_func: Removing /var/cache/salt/minion/proc/20160106190445406152
[WARNING ] Unable to send mine data to master.
[DEBUG   ] Handling event '__master_disconnected\n\n\x82\xa6_stamp\xba2016-01-06T19:09:05.604375\xa6master\xbasmaster1-dusw.xxxx.com'
[INFO    ] Running scheduled job: __master_alive
[DEBUG   ] schedule: This job was scheduled with jid_include, adding to cache (jid_include defaults to True)
[DEBUG   ] schedule: This job was scheduled with a max number of 2
[DEBUG   ] schedule.handle_func: Checking job against fun status.master: {'fun': 'mine.update', 'jid': '20160106190606192342', 'pid': 23297, 'id': 'dusw1-content17', 'schedule': '__mine_interval'}
[DEBUG   ] schedule.handle_func: Checking job against fun status.master: {'fun': 'mine.update', 'jid': '20160106190506155653', 'pid': 23219, 'id': 'dusw1-content17', 'schedule': '__mine_interval'}
[DEBUG   ] schedule.handle_func: Checking job against fun status.master: {'fun': 'status.master', 'jid': '20160106190905597199', 'pid': 23478, 'id': 'dusw1-content17', 'schedule': '__master_alive'}
[DEBUG   ] schedule.handle_func: Incrementing jobcount, now 1, maxrunning is 2
[DEBUG   ] schedule.handle_func: adding this job to the jobcache with data {'fun': 'status.master', 'jid': '20160106190906344335', 'pid': 23520, 'id': 'dusw1-content17', 'schedule': '__master_alive'}
[ERROR   ] Exception in callback <functools.partial object at 0x7fc734412310>
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/tornado/ioloop.py", line 592, in _run_callback
    ret = callback()
  File "/usr/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
    return fn(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/tornado/ioloop.py", line 598, in <lambda>
    self.add_future(ret, lambda f: f.result())
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 230, in wrapper
    yielded = next(result)
  File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 1537, in handle_event
    raise Exception()
Exception
[DEBUG   ] Handling event '_minion_mine\n\n\x85\xa5clear\xc2\xa3cmd\xa5_mine\xa4data\x80\xa2id\xafdusw1-content17\xa6_stamp\xba2016-01-06T19:06:06.197242'
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'dusw1-content17', 'tcp://172.31.47.127:4506', 'aes')
[DEBUG   ] Initializing new SAuth for ('/etc/salt/pki/minion', 'dusw1-content17', 'tcp://172.31.47.127:4506')
[DEBUG   ] SaltEvent PUB socket URI: ipc:///var/run/salt/minion/minion_event_a6604d7069_pub.ipc
[DEBUG   ] SaltEvent PULL socket URI: ipc:///var/run/salt/minion/minion_event_a6604d7069_pull.ipc
[DEBUG   ] Sending event - data = {'_stamp': '2016-01-06T19:09:06.359705', 'master': 'smaster2-dusw.xxxx.com'}
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'dusw1-content17', 'tcp://172.31.47.127:4506', 'aes')
[DEBUG   ] Initializing new SAuth for ('/etc/salt/pki/minion', 'dusw1-content17', 'tcp://172.31.47.127:4506')
[DEBUG   ] Error deleting fd from IOLoop
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/tornado/ioloop.py", line 715, in remove_handler
    self._impl.unregister(fd)
  File "/usr/lib/python2.7/dist-packages/zmq/eventloop/ioloop.py", line 125, in unregister
    return self._poller.unregister(fd)
  File "/usr/lib/python2.7/dist-packages/zmq/sugar/poll.py", line 80, in unregister
    idx = self._map.pop(socket)
KeyError: None
[DEBUG   ] SaltReqTimeoutError, retrying. (1/3)
[DEBUG   ] SaltReqTimeoutError, retrying. (1/3)
[DEBUG   ] SaltReqTimeoutError, retrying. (2/3)
[DEBUG   ] Error deleting fd from IOLoop
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/tornado/ioloop.py", line 715, in remove_handler
    self._impl.unregister(fd)
  File "/usr/lib/python2.7/dist-packages/zmq/eventloop/ioloop.py", line 125, in unregister
    return self._poller.unregister(fd)
  File "/usr/lib/python2.7/dist-packages/zmq/sugar/poll.py", line 80, in unregister
    idx = self._map.pop(socket)
KeyError: None
[DEBUG   ] SaltReqTimeoutError, retrying. (2/3)
[DEBUG   ] SaltReqTimeoutError, retrying. (3/3)
[DEBUG   ] SaltReqTimeoutError, retrying. (3/3)
[WARNING ] Unable to send mine data to master.
[DEBUG   ] Handling event '_minion_mine\n\n\x85\xa5clear\xc2\xa3cmd\xa5_mine\xa4data\x80\xa2id\xafdusw1-content17\xa6_stamp\xba2016-01-06T19:11:06.310601'
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'dusw1-content17', 'tcp://172.31.47.127:4506', 'aes')
[DEBUG   ] Initializing new SAuth for ('/etc/salt/pki/minion', 'dusw1-content17', 'tcp://172.31.47.127:4506')
[ERROR   ] Unhandled exception running status.master
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/utils/schedule.py", line 710, in handle_func
    channel.send(load)
  File "/usr/lib/python2.7/dist-packages/salt/utils/async.py", line 73, in wrap
    ret = self._block_future(ret)
  File "/usr/lib/python2.7/dist-packages/salt/utils/async.py", line 83, in _block_future
    return future.result()
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 876, in run
    yielded = self.gen.throw(*exc_info)
  File "/usr/lib/python2.7/dist-packages/salt/transport/zeromq.py", line 231, in send
    ret = yield self._crypted_transfer(load, tries=tries, timeout=timeout)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 870, in run
    value = future.result()
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 876, in run
    yielded = self.gen.throw(*exc_info)
  File "/usr/lib/python2.7/dist-packages/salt/transport/zeromq.py", line 199, in _crypted_transfer
    ret = yield _do_transfer()
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 870, in run
    value = future.result()
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 876, in run
    yielded = self.gen.throw(*exc_info)
  File "/usr/lib/python2.7/dist-packages/salt/transport/zeromq.py", line 185, in _do_transfer
    tries=tries,
  File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 870, in run
    value = future.result()
  File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
SaltReqTimeoutError: Message timed out
[DEBUG   ] schedule.handle_func: Removing /var/cache/salt/minion/proc/20160106190906344335

Salt info

Salt Version:
           Salt: 2015.8.3

Dependency Versions:
         Jinja2: 2.7.2
       M2Crypto: 0.22
           Mako: 0.9.1
         PyYAML: 3.10
          PyZMQ: 14.0.1
         Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.4
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.2
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.3.0
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: Not Installed
        timelib: Not Installed

System Versions:
           dist: Ubuntu 14.04 trusty
        machine: x86_64
        release: 3.13.0-74-generic
         system: Ubuntu 14.04 trusty

Activity

  1. jakehilton commented on Jan 6, 2016

    @jakehilton
    Author

    I do see an event from above where it seem to notice the master is disconnected.. but then it throws an exception

    [DEBUG   ] Handling event '__master_disconnected\n\n\x82\xa6_stamp\xba2016-01-06T19:09:05.604375\xa6master\xbasmaster1-dusw.xxxx.com'
    [INFO    ] Running scheduled job: __master_alive
    [DEBUG   ] schedule: This job was scheduled with jid_include, adding to cache (jid_include defaults to True)
    [DEBUG   ] schedule: This job was scheduled with a max number of 2
    [DEBUG   ] schedule.handle_func: Checking job against fun status.master: {'fun': 'mine.update', 'jid': '20160106190606192342', 'pid': 23297, 'id': 'dusw1-content17', 'schedule': '__mine_interval'}
    [DEBUG   ] schedule.handle_func: Checking job against fun status.master: {'fun': 'mine.update', 'jid': '20160106190506155653', 'pid': 23219, 'id': 'dusw1-content17', 'schedule': '__mine_interval'}
    [DEBUG   ] schedule.handle_func: Checking job against fun status.master: {'fun': 'status.master', 'jid': '20160106190905597199', 'pid': 23478, 'id': 'dusw1-content17', 'schedule': '__master_alive'}
    [DEBUG   ] schedule.handle_func: Incrementing jobcount, now 1, maxrunning is 2
    [DEBUG   ] schedule.handle_func: adding this job to the jobcache with data {'fun': 'status.master', 'jid': '20160106190906344335', 'pid': 23520, 'id': 'dusw1-content17', 'schedule': '__master_alive'}
    [ERROR   ] Exception in callback <functools.partial object at 0x7fc734412310>
    Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/tornado/ioloop.py", line 592, in _run_callback
        ret = callback()
      File "/usr/lib/python2.7/dist-packages/tornado/stack_context.py", line 275, in null_wrapper
        return fn(*args, **kwargs)
      File "/usr/lib/python2.7/dist-packages/tornado/ioloop.py", line 598, in <lambda>
        self.add_future(ret, lambda f: f.result())
      File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
        raise_exc_info(self._exc_info)
      File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 230, in wrapper
        yielded = next(result)
      File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 1537, in handle_event
        raise Exception()
    Exception
    
  2. added
    bug
    severity-medium
    P3
    Core
    on Jan 7, 2016
  3. added this to the Approved milestone on Jan 7, 2016
  4. mou commented on Feb 2, 2016

    @mou
    Contributor

    Is it possible what problem hides in next rows? For me it's looks like replacing list of masters from config with a single value.

    
                    if self.opts['master_type'] == 'failover':
                        log.info('Trying to tune in to next master from master-list')
    
                        if hasattr(self, 'pub_channel'):
                            self.pub_channel.on_recv(None)
                            if hasattr(self.pub_channel, 'close'):
                                self.pub_channel.close()
                            del self.pub_channel
    
                        # if eval_master finds a new master for us, self.connected
                        # will be True again on successful master authentication
                        master, self.pub_channel = yield self.eval_master(
                                                            opts=self.opts,
                                                            failed=True)
                        if self.connected:
                            self.opts['master'] = master
    
  5. cachedout commented on Feb 2, 2016

    @cachedout
    Contributor

    Likely already fixed here: #30796

  6. mou commented on Feb 2, 2016

    @mou
    Contributor

    Thanks @cachedout. Was this fix released?

  7. cachedout commented on Feb 2, 2016

    @cachedout
    Contributor

    @mou No. It was merged just this morning.

  8. mou commented on Feb 2, 2016

    @mou
    Contributor

    Think i was wrong. But there are still assignment to self.opts['master']. What does yield returns? Does it return a list if there was a list of masters?

  9. Ch3LL commented on Feb 4, 2016

    @Ch3LL
    Contributor

    I tested this new change and it introduces a new problem, now it won't even failover once. Test case:

    1. start both masters and minion
    2. verify i can test.ping minion
    3. stop first master in list
      4.. the minion does not even fail over now. I just see the following:
    [DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'minion1', 'tcp://192.168.50.10:4506', 'aes')
    [DEBUG   ] Initializing new SAuth for ('/etc/salt/pki/minion', 'minion1', 'tcp://192.168.50.10:4506')
    

    And I have let this sit for 20 minutes with no successful failover.

    Here are my settings:

    master:
      - 192.168.50.10
      - 192.168.50.11
    
    master_type: failover
    master_alive_interval: 10
    retry_dns: 0
    

    I also tested the following test-case:

    1. only start second master in the list
    2. start minion
      And i'm seeing similar behavior as it never fails over and i just continue to see Process manager iteration in the log
    [DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'minion1', 'tcp://192.168.50.10:4506', 'clear')
    [DEBUG   ] Process manager iteration
    [DEBUG   ] Process manager iteration
    [DEBUG   ] Process manager iteration
    [DEBUG   ] Process manager iteration
    ...
    [DEBUG   ] Process manager iteration
    [DEBUG   ] Process manager iteration
    [DEBUG   ] Process manager iteration
    
    [root@saltmaster ~]# salt --version
    salt 2015.8.4-4893-g616eb79 (Beryllium)
    
  10. DmitryKuzmenko commented on Feb 26, 2016

    @DmitryKuzmenko
    Contributor

    #31512 together with #30796 fix this.
    I've tested this case on develop branch.

  11. added
    fixed-pls-verify
    on Feb 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

CoreMulti-MasterP3bugfixed-pls-verifyseverity-medium

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions