salt icon indicating copy to clipboard operation
salt copied to clipboard

salt-minion hangs randomly

Open syedaali opened this issue 11 years ago • 18 comments

salt-minion appears to hang randomly, restarting salt-minion service or even the AWS instance on which it is running is not helping. I have had to terminate the instance and create a new one since I could not find any other way of getting it to work.

root@ip-172-16-107-182:~# tail -f /var/log/salt/minion
2015-11-13 18:31:11,461 [salt.cli.daemons ][INFO    ][27818] The salt minion is starting up
2015-11-13 18:31:11,461 [salt.minion      ][INFO    ][27818] Minion is starting as user 'root'
2015-11-13 18:31:11,462 [salt.utils.event ][INFO    ][27818] Starting pub socket on ipc:///var/run/salt/minion/minion_event_765ef858d2_pub.ipc
2015-11-13 18:31:11,462 [salt.utils.event ][INFO    ][27818] Starting pull socket on ipc:///var/run/salt/minion/minion_event_765ef858d2_pull.ipc
2015-11-13 18:33:15,992 [salt.cli.daemons ][INFO    ][27818] The salt minion is shut down
2015-11-13 18:34:28,696 [salt.cli.daemons ][INFO    ][1216] Setting up the Salt Minion "playback_worker_test"
2015-11-13 18:34:29,727 [salt.cli.daemons ][INFO    ][1216] The salt minion is starting up
2015-11-13 18:34:29,727 [salt.minion      ][INFO    ][1216] Minion is starting as user 'root'
2015-11-13 18:34:29,728 [salt.utils.event ][INFO    ][1216] Starting pub socket on ipc:///var/run/salt/minion/minion_event_765ef858d2_pub.ipc
2015-11-13 18:34:29,728 [salt.utils.event ][INFO    ][1216] Starting pull socket on ipc:///var/run/salt/minion/minion_event_765ef858d2_pull.ipc

syedaali avatar Nov 13 '15 19:11 syedaali

It's getting concerning to see this behavior on more minions:

root@minion:~# salt-minion -l debug
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] Configuration file path: /etc/salt/minion
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[INFO    ] Setting up the Salt Minion "minion"
[DEBUG   ] Created pidfile: /var/run/salt-minion.pid
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Including configuration from '/etc/salt/minion.d/_schedule.conf'
[DEBUG   ] Reading configuration from /etc/salt/minion.d/_schedule.conf
[DEBUG   ] Please install 'virt-what' to improve results of the 'virtual' grain.
[INFO    ] The salt minion is starting up
[INFO    ] Minion is starting as user 'root'
[DEBUG   ] AsyncEventPublisher PUB socket URI: ipc:///var/run/salt/minion/minion_event_02e4d5f808_pub.ipc
[DEBUG   ] AsyncEventPublisher PULL socket URI: ipc:///var/run/salt/minion/minion_event_02e4d5f808_pull.ipc
[INFO    ] Starting pub socket on ipc:///var/run/salt/minion/minion_event_02e4d5f808_pub.ipc
[INFO    ] Starting pull socket on ipc:///var/run/salt/minion/minion_event_02e4d5f808_pull.ipc
[DEBUG   ] Minion 'minion' trying to tune in
[DEBUG   ] sync_connect_master
[DEBUG   ] Initializing new SAuth for ('/etc/salt/pki/minion', 'minion', 'tcp://minion-ip:4506')
[DEBUG   ] Generated random reconnect delay between '1000ms' and '11000ms' (2837)
[DEBUG   ] Setting zmq_reconnect_ivl to '2837ms'
[DEBUG   ] Setting zmq_reconnect_ivl_max to '11000ms'
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'minion', 'tcp://minion-ip:4506', 'clear')
root@salt-master:~# salt  minion state.highstate -l debug
[DEBUG   ] Reading configuration from /etc/salt/master
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: ip-master-ip.us-west-2.compute.internal
[DEBUG   ] Missing configuration file: /home/syed.ali/.saltrc
[DEBUG   ] Configuration file path: /etc/salt/master
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[DEBUG   ] Reading configuration from /etc/salt/master
[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: ip-master-ip.us-west-2.compute.internal
[DEBUG   ] Missing configuration file: /home/syed.ali/.saltrc
[DEBUG   ] MasterEvent PUB socket URI: ipc:///var/run/salt/master/master_event_pub.ipc
[DEBUG   ] MasterEvent PULL socket URI: ipc:///var/run/salt/master/master_event_pull.ipc
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'ip-master-ip.us-west-2.compute.internal_master', 'tcp://127.0.0.1:4506', 'clear')
[DEBUG   ] LazyLoaded local_cache.get_load
[DEBUG   ] get_iter_returns for jid 20151117033830688275 sent to set(['minion']) will timeout at 03:38:35.691076
[DEBUG   ] Checking whether jid 20151117033830688275 is still running
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/master', 'ip-master-ip.us-west-2.compute.internal_master', 'tcp://127.0.0.1:4506', 'clear')
[DEBUG   ] LazyLoaded no_return.output
minion:
    Minion did not return. [Not connected]
# salt --versions
Salt Version:
           Salt: 2015.8.1

Dependency Versions:
         Jinja2: 2.7.2
       M2Crypto: Not Installed
           Mako: 0.9.1
         PyYAML: 3.10
          PyZMQ: 14.4.0
         Python: 2.7.6 (default, Mar 22 2014, 22:59:56)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.4
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.4.2
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          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: 0.8.2
        timelib: Not Installed

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

syedaali avatar Nov 17 '15 03:11 syedaali

Here is the strace:

read(33, "-----BEGIN PUBLIC KEY-----\nMIIBI"..., 4096) = 450
read(33, "", 4096)                      = 0
close(33)                               = 0
munmap(0x7f969aafe000, 4096)            = 0
clock_gettime(CLOCK_MONOTONIC, {637, 968706361}) = 0
poll([{fd=17, events=POLLIN}, {fd=24, events=POLLIN}, {fd=31, events=POLLIN}], 3, 0) = 3 ([{fd=17, revents=POLLIN}, {fd=24, revents=POLLIN}, {fd=31, revents=POLLIN}])
poll([{fd=24, events=POLLIN}], 1, 0)    = 1 ([{fd=24, revents=POLLIN}])
read(24, "\1\0\0\0\0\0\0\0", 8)         = 8
poll([{fd=24, events=POLLIN}], 1, 0)    = 0 (Timeout)
poll([{fd=31, events=POLLIN}], 1, 0)    = 1 ([{fd=31, revents=POLLIN}])
read(31, "\1\0\0\0\0\0\0\0", 8)         = 8
poll([{fd=31, events=POLLIN}], 1, 0)    = 0 (Timeout)
fstat(17, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lseek(17, 0, SEEK_CUR)                  = -1 ESPIPE (Illegal seek)
read(17, "x", 6)                        = 1
read(17, 0x7f9692002265, 5)             = -1 EAGAIN (Resource temporarily unavailable)
fstat(17, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lseek(17, 0, SEEK_CUR)                  = -1 ESPIPE (Illegal seek)
read(17, 0x7f9692002234, 6)             = -1 EAGAIN (Resource temporarily unavailable)
clock_gettime(CLOCK_MONOTONIC, {637, 970283695}) = 0
poll([{fd=17, events=POLLIN}, {fd=24, events=POLLIN}, {fd=31, events=POLLIN}], 3, 0) = 0 (Timeout)
poll([{fd=24, events=POLLIN}], 1, 0)    = 0 (Timeout)
poll([{fd=31, events=POLLIN}], 1, 0)    = 0 (Timeout)
clock_gettime(CLOCK_MONOTONIC, {637, 970692611}) = 0
poll([{fd=17, events=POLLIN}, {fd=24, events=POLLIN}, {fd=31, events=POLLIN}], 3, 3600000) = ? ERESTART_RESTARTBLOCK (Interrupted by signal)
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
restart_syscall(<... resuming interrupted call ...>) = ? ERESTART_RESTARTBLOCK (Interrupted by signal)
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
restart_syscall(<... resuming interrupted call ...>) = ? ERESTART_RESTARTBLOCK (Interrupted by signal)
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
restart_syscall(<... resuming interrupted call ...>) = ? ERESTART_RESTARTBLOCK (Interrupted by signal)
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
restart_syscall(<... resuming interrupted call ...>

syedaali avatar Nov 17 '15 03:11 syedaali

@syedaali, thanks for the report. How have you installed salt on the minions that are failing?

@cachedout, do you have any ideas here?

jfindlay avatar Nov 17 '15 16:11 jfindlay

Yes, minion is installed on the AWS instances that are failing. The minions are installed via salt-cloud bootstrap.sh. I have tried to stop the minion and run 'salt-call state.highstate -l debug' and I have tried salt-minion -l debug, both hang.

syedaali avatar Nov 17 '15 17:11 syedaali

@syedaali, is it possible for you to try a reduced highstate and narrow in on what may be causing this problem? Can you post or describe a reproducible test case?

jfindlay avatar Nov 17 '15 20:11 jfindlay

These lseeks are pretty interesting. Are you you by chance using file.seek_read or file.seek_write in your state run? It's hard to tell from that strace whether that file handle that's throwing those errors is attached to a socket or a text file of some kind.

Is there anything in the system or kernel logs that's suspicious?

cachedout avatar Nov 19 '15 20:11 cachedout

@syedaali Did you see my comment above? We'd love to get this fixed but we'll need more information before we can proceed here.

cachedout avatar Dec 01 '15 18:12 cachedout

I have been unable to replicate this issue. I've created a few different minions (v2015.8.1) using AWS and have been unsuccessful at getting a minion to hang or not respond. Awaiting responses to look further into this.

arroyoc avatar Dec 07 '15 21:12 arroyoc

I am not using file.seek_read or file.seek_write , but I am using file.managed, would that be an issue? Also #29453 appears to be related. I went ahead and upgraded PyZMQ and ZMQ from 14.4.0 and 4.0.4 respectively to 15.1.10 and 4.1.2 (see below), but that did not help. I did this by removing the apt-package and using pip to install.

salt --versions Salt Version: Salt: 2015.8.3

Dependency Versions: Jinja2: 2.7.2 M2Crypto: Not Installed Mako: 0.9.1 PyYAML: 3.10 PyZMQ: 15.1.0 Python: 2.7.6 (default, Jun 22 2015, 17:58:13) RAET: Not Installed Tornado: 4.2.1 ZMQ: 4.1.2 cffi: Not Installed cherrypy: Not Installed dateutil: 2.4.2 gitdb: 0.5.4 gitpython: 0.3.2 RC1 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: 0.8.2 timelib: Not Installed

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

syedaali avatar Dec 11 '15 21:12 syedaali

So we have been completely unable to reproduce this on our systems. I think there's something system specific which we do want to address, but have been unable to discover. Any chance you could come up with a vagrant setup that can reproduce this, or could you quarantine a machine that's exhibiting this and give one of us access to that machine?

basepi avatar Jan 07 '16 17:01 basepi

@syedaali Did you see my comment above?

basepi avatar Jan 26 '16 16:01 basepi

Hi, Sorry for the late response. We are unable to restart the minion without it hanging in some cases. Basically we end up re-creating the AWS instance, because no matter what we do, the minion is unable to connect to the master. I am not sure I can provide a reduced state without violating company policy, on the plus side we bought Salt Enterprise support. I will open a case with them and provide the full state, once they are able to debug the issue, I can provide more update here. Thanks

syedaali avatar Jan 27 '16 17:01 syedaali

Thanks for the update, @syedaali

basepi avatar Jan 27 '16 21:01 basepi

ZD-621 has been created and linked

rickh563 avatar Jan 28 '16 21:01 rickh563

Waiting for a response in ZD

meggiebot avatar Mar 01 '16 16:03 meggiebot

Never received a response in ZD, ZD ticket was closed. Leaving this item open in case someone else is running into the same issue.

meggiebot avatar Mar 07 '16 17:03 meggiebot

I'm seeing the same thing (consistently rather than randomly) on Centos 6 with Salt installed from the SaltStack Package Repo.

# salt-minion -l debug
[DEBUG   ] Reading configuration from /etc/salt/minion
[DEBUG   ] Configuration file path: /etc/salt/minion
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[INFO    ] Setting up the Salt Minion "centos6-test"
[DEBUG   ] Created pidfile: /var/run/salt-minion.pid
[DEBUG   ] Reading configuration from /etc/salt/minion
[WARNING ] IMPORTANT: Do not use md5 hashing algorithm! Please set "hash_type" to SHA256 in Salt Minion config!
[INFO    ] The Salt Minion is starting up
[INFO    ] Minion is starting as user 'root'
[DEBUG   ] AsyncEventPublisher PUB socket URI: ipc:///var/run/salt/minion/minion_event_d4f389e8dc_pub.ipc
[DEBUG   ] AsyncEventPublisher PULL socket URI: ipc:///var/run/salt/minion/minion_event_d4f389e8dc_pull.ipc
[INFO    ] Starting pub socket on ipc:///var/run/salt/minion/minion_event_d4f389e8dc_pub.ipc
[INFO    ] Starting pull socket on ipc:///var/run/salt/minion/minion_event_d4f389e8dc_pull.ipc
[DEBUG   ] Minion 'centos6-test' trying to tune in
[DEBUG   ] Initializing new SAuth for ('/etc/salt/pki/minion', 'centos6-test', 'tcp://192.168.226.90:4506')
[DEBUG   ] Generated random reconnect delay between '1000ms' and '11000ms' (3390)
[DEBUG   ] Setting zmq_reconnect_ivl to '3390ms'
[DEBUG   ] Setting zmq_reconnect_ivl_max to '11000ms'
[DEBUG   ] Initializing new AsyncZeroMQReqChannel for ('/etc/salt/pki/minion', 'centos6-test', 'tcp://192.168.226.90:4506', 'clear')

After Ctrl+C:

^C[INFO    ] Executing command state.highstate with jid req
[DEBUG   ] Command details {'fun': 'state.highstate', 'jid': 'req', 'ret': '', 'arg': []}
Process Process-1:1:
Traceback (most recent call last):
  File "/usr/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap
    self.run()
  File "/usr/lib/python2.6/multiprocessing/process.py", line 88, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python2.6/site-packages/salt/minion.py", line 1041, in _thread_return
    fn_ = os.path.join(minion_instance.proc_dir, data['jid'])
AttributeError: 'Minion' object has no attribute 'proc_dir'
[INFO    ] The Salt Minion is shut down
[ERROR   ] Minion failed to start
[WARNING ] ** Restarting minion **
[INFO    ] Sleeping random_reauth_delay of 4 seconds
# salt-minion --versions
Salt Version:
           Salt: 2015.8.8

Dependency Versions:
         Jinja2: unknown
       M2Crypto: 0.20.2
           Mako: Not Installed
         PyYAML: 3.10
          PyZMQ: 2.2.0
         Python: 2.6.6 (r266:84292, Jul 23 2015, 14:41:34)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.3
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
        libgit2: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: Not Installed
        timelib: Not Installed

System Versions:
           dist: centos 6.7 Final
        machine: i686
        release: 2.6.32-573.18.1.el6.i686
         system: CentOS 6.7 Final

jamchamb avatar Mar 24 '16 19:03 jamchamb

Never mind, updating PyZMQ to 14.5.0 fixed it.

jamchamb avatar Mar 24 '16 20:03 jamchamb