Enforce a minimum kernel version
Problem:
Attempting to spin up salt-minion on a Debian Squeeze container running under OpenVZ (i.e., in a paravirtualized environment) it never sends anything to the master. The logs say nothing, not even at the debug/trace/garbage level. strace in no-follow-forks mode says it's timing out waiting for the poll() syscall to finish.
strace in follow-forks mode shows the minion spawning child processes that say something like this in a tight loop:
< snip >
[pid 3601] epoll_wait(11, {}, 256, 1) = 0
[pid 3601] clock_gettime(CLOCK_MONOTONIC, {94678281, 344987642}) = 0
[pid 3601] socket(PF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = -1 EINVAL (Invalid argument)
[pid 3601] epoll_wait(11, {}, 256, 183) = 0
[pid 3601] clock_gettime(CLOCK_MONOTONIC, {94678281, 528004609}) = 0
[pid 3601] socket(PF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = -1 EINVAL (Invalid argument)
< snip >
...until they eventually give up and the parent forks a new one, and makes it try again.
The kernel on the host is (don't laugh):
$ uname -srmo
Linux 2.6.18-028stab060.8 i686 GNU/Linux
...and it is shared with all the other containers on the box. It cannot be changed. If there is a minimum kernel version required for the functionality that 0MQ and/or Salt needs, it should be checked for and a "go pound sand" message should result.
Expected result:
salt-minion detects that it isn't going to be able to work in a given environment and either gracefully exits with an error or explodes violently
Actual Result:
salt-minion says it's starting and refuses to establish communications with the master, with zero outward indication in logs, etc. that it's not working.
This is not a min kernel version, Salt runs fine on RHEL 5, and that runs 2.6.18. In fact, I have no idea what this could possibly be...
If you run a minion in the foreground: salt-minion -l debug do you get any additional output? and what is the trace when you ctrl-c it when running in the foreground?
The only reason I implicate the kernel is because I had a "partial upgrade" of Debian Lenny (Linux 2.6.26) to Debian Squeeze (Linux 2.6.32) upgrade the entire runtime but not the kernel. It behaved in an identical fashion, and started working correctly once the proper kernel was booted.
But here's the results you asked for, the timestamps should indicate that I started it, waited for the key to show up on the master for 30 seconds, hit Ctrl-C, waited 30 seconds, and hit Ctrl-C again. This is the alpha and omega of the output I received:
# salt-minion -l debug
12:44:26,765 [salt.minion ][WARNING ] Starting the Salt Minion
12:44:26,769 [salt.minion ][DEBUG ] Attempting to authenticate with the Salt Master
12:44:26,772 [salt.crypt ][DEBUG ] Loaded minion key: /etc/salt/pki/minion.pem
12:44:56,306 [salt ][WARNING ] Stopping the Salt Minion
Exception KeyboardInterrupt in <zmq.core.context.Context object at 0x9b354ac> ignored
Exiting on Ctrl-c
The strace output was (slightly) more illuminating as to what was happening.
Well, this is a fine kettle of fish! I have no idea what could be causing this and have never seen anything like it, my guess is that it is in zeromq. What version of zeromq are you running? I will do some research
ii libzmq1 2.1.11-1 ZeroMQ lightweight messaging kernel (shared library)
ii python-zmq 2.1.10-1chl1~squeeze1 0MQ is a fast messaging library
Can we see if making pyzmq the same version as libzmq helps?
I cribbed some modern pyzmq from Debian Sid and thwacked on the control/rules files until they built under Squeeze. It does not appear to have affected the situation at all:
# dpkg -l | grep zmq
ii libzmq1 2.1.11-1 ZeroMQ lightweight messaging kernel (shared library)
ii python-zmq 2.1.11-1 Python bindings for 0MQ library
# salt-minion -l debug
14:56:03,855 [salt.minion ][WARNING ] Starting the Salt Minion
14:56:03,855 [salt.minion ][DEBUG ] Attempting to authenticate with the Salt Master
14:56:03,872 [salt.crypt ][DEBUG ] Loaded minion key: /etc/salt/pki/minion.pem
14:56:36,589 [salt ][WARNING ] Stopping the Salt Minion
la la la it's not dead yet la la la let's hit Ctrl-C again
Exception KeyboardInterrupt in <zmq.core.context.Context object at 0x94e950c> ignored
Exiting on Ctrl-c
It might be a binary incompatibility then, but I am still stumped
Can this still be reproduced? Do we need to keep hunting this?
Hi. I love Salt and wanted to say thanks first off.
I'm having the same kind of issue with a different environment and output that I thought may be related to this (if not maybe the issue can be moved into a separate ticket. First off the environment is a OpenVZ container running Debian 6 32bit. When I issue a command from the master I never get a response. Calling test.ping from the master results in absolutely no additional logfile entries on the minion (even when the log level is set to 'garbage'.) I tried using salt-call and get the following:
rnd@vps:~$ sudo salt-call test.ping
[INFO ] Loaded configuration file: /etc/salt/minion
[WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not
be accurate.
[WARNING ] Although 'lspci' was found in path, the current user cannot execute it. Grains output might not be
accurate.
[WARNING ] Both 'dmidecode' and 'lspci' failed to execute, either because they do not exist on the system of the
user running this instance does not have the necessary permissions to execute them. Grains output might not be
accurate.
local: True
Those same warning level messages are also present in the daemon log files but only seem to occur during startup. Here's some basic trouble shooting I did including kernel version (even though it doesn't seem likely to be the culprit here.):
rnd@vps:~$ sudo dmidecode
# dmidecode 2.9
/dev/mem: Operation not permitted
rnd@vps:~$ sudo lspci
pcilib: Cannot open /proc/bus/pci
lspci: Cannot find any working access method.
rnd@vps:~$ ls -al {/dev/mem,/proc/bus/pci}
ls: cannot access /proc/bus/pci: No such file or directory
crw-r----- 1 root kmem 1, 1 Jun 9 2012 /dev/mem
rnd@vps:~$ uname -r
2.6.32-042stab068.8
Any ideas? Do you think this is related to the above or should I throw this in a new ticket?
I ran salt-minion using strace:
$ sudo strace -o debug/salt-minion -ff salt-minion
I tar balled the resulting files if anyone thinks it might help. During the run I attempted once to call test.ping and a quick grep through the trace files do seem to indicate bidirectional communication ('sendto' calls with the minion's fqdn in them, 'recvfrom' calls with the master's fqdn in them. I'm not particularly gifted with these kinds of files so if anyone thinks they might help they are available at http://rnd42.com/salt-minion-strace-ff.tar.gz . It seems that all the action is in the (significantly larger, 1.2 MB uncompressed) file salt-mainion.4508.
This does look like some sort of ZeroMQ interaction, and the above problem was also on OpenVZ which makes me wonder. What does: salt-call --versions-report print out on the minion? Also, what does it look like if you run the minion in the foreground in debug mode and then send it a call from the master? I am going through the strace now, thank you for being so complete, hopefully we can just fix this with something like a zeromq update (crosses fingers)
Copy/Paste from terminal:
rnd@vps1:~$ sudo salt-call --versions-report
Salt: 0.11.1
Python: 2.6.6 (r266:84292, Dec 27 2010, 00:02:40)
Jinja2: 2.5.5
M2Crypto: 0.20.1
msgpack-python: 0.1.10
msgpack-pure: not installed
pycrypto: 2.1.0
PyYAML: 3.09
PyZMQ: 2.2.0
rnd@vps1:~$ sudo salt-minion -l debug
[INFO ] Loaded configuration file: /etc/salt/minion
[WARNING ] Setting up the Salt Minion "vps1.ownthine.com"
[DEBUG ] loading grain in ['/var/cache/salt/minion/extmods/grains', '/usr/lib/pymodules/python2.6/salt/grains']
[DEBUG ] Skipping /var/cache/salt/minion/extmods/grains, it is not a directory
[WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
[WARNING ] Although 'lspci' was found in path, the current user cannot execute it. Grains output might not be accurate.
[WARNING ] Both 'dmidecode' and 'lspci' failed to execute, either because they do not exist on the system of the user running this instance does not have the necessary permissions to execute them. Grains output might not be accurate.
[DEBUG ] Attempting to authenticate with the Salt Master at 69.247.68.58
[DEBUG ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG ] Decrypting the current master AES key
[DEBUG ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[INFO ] Authentication with master successful!
[DEBUG ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG ] Decrypting the current master AES key
[DEBUG ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG ] Loaded minion key: /etc/salt/pki/minion/minion.pem
[DEBUG ] loading grain in ['/var/cache/salt/minion/extmods/grains', '/usr/lib/pymodules/python2.6/salt/grains']
[DEBUG ] Skipping /var/cache/salt/minion/extmods/grains, it is not a directory
[WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
[WARNING ] Although 'lspci' was found in path, the current user cannot execute it. Grains output might not be accurate.
[WARNING ] Both 'dmidecode' and 'lspci' failed to execute, either because they do not exist on the system of the user running this instance does not have the necessary permissions to execute them. Grains output might not be accurate.
[DEBUG ] loading module in ['/var/cache/salt/minion/extmods/modules', '/usr/lib/pymodules/python2.6/salt/modules']
[DEBUG ] Skipping /var/cache/salt/minion/extmods/modules, it is not a directory
[DEBUG ] Loaded groupadd as virtual group
[DEBUG ] Loaded linux_sysctl as virtual sysctl
[DEBUG ] Loaded parted as virtual partition
[DEBUG ] Loaded apt as virtual pkg
[DEBUG ] Loaded debian_service as virtual service
[DEBUG ] Loaded useradd as virtual user
[DEBUG ] Loaded debconfmod as virtual debconf
[DEBUG ] Loaded cmdmod as virtual cmd
[DEBUG ] Loaded djangomod as virtual django
[DEBUG ] Loaded brew as virtual None
[DEBUG ] loading returner in ['/var/cache/salt/minion/extmods/returners', '/usr/lib/pymodules/python2.6/salt/returners']
[DEBUG ] Skipping /var/cache/salt/minion/extmods/returners, it is not a directory
[DEBUG ] Loaded syslog_return as virtual syslog
[DEBUG ] Created pidfile: /var/run/salt-minion.pid
[DEBUG ] Chowned pidfile: /var/run/salt-minion.pid to user: root
[INFO ] Minion is starting as user 'root'
[DEBUG ] Minion "vps1.ownthine.com" trying to tune in
[DEBUG ] Minion PUB socket URI: ipc:///var/run/salt/minion/minion_event_dede89302470377edd8c01bedb960cd4_pub.ipc
[DEBUG ] Minion PULL socket URI: ipc:///var/run/salt/minion/minion_event_dede89302470377edd8c01bedb960cd4_pull.ipc
# Calling test.ping:
# Command timed out on master waiting for minion...^C[WARNING ] Stopping the Salt Minion
Exiting on Ctrl-c
Thanks for helping with this.
Wow, it happens as soon as the recv is called, looks like it could be a zeromq issue with OpenVZ, this does help, but not as much as I would like.
Well, I did a bit of research. There is only one bug on the ZMQ issue tracker that mentions OpenVZ: https://zeromq.jira.com/browse/LIBZMQ-273 . It's an interesting corner case to consider however it doesn't seem likely to be the culprit as it affects version 2.1.10 and aptitude reports that I have 2.2.0+dfsg-2~bpo60+1 installed, on the other hand I wonder if python-zmq would need to take similar measures perhaps? I'm not really sure how I'd go about checking if O_CLOEXEC works properly in my environment or even if the kernel reports that it supports it at all.
I also tried uninstalling salt and building the package from the git master branch as well as installing the master so communication would be over localhost, that wasn't working particularly well. For some reason the minion never got it's key to the master so I could approve it with salt-key. I was going to try again with the version from squeeze-backports but it doesn't seem to be available there any more.
rnd@vps1:~$ sudo apt-get update
...
rnd@vps1:~$ sudo apt-get -t squeeze-backports install salt-minion salt-master
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package salt-minion
E: Unable to locate package salt-master
I guess I can rebuild salt the way I originally had, checking out tag v0.11.1 and using 'fakeroot' from there... I'm about to the point that if somebody wants to investigate further I might be willing to send them a temporary username and key pair for SSH access.
My plate is very full right now, but I will look into reproducing it and spending more time with the stack trace, we will find it!
Well, I setup a master on the same system and had no further communication issues. My guess is that there is some interference from firewalls or proxies between my VPS and the master system I was trying to use or perhaps the virtual ethernet interfaces themselves. I tried inverting the system so the VPS was the master and put the system I had been using as a master into minion mode and it all works fine then... I really didn't want to have to run the master on this smaller constrained environment of a VPS but don't seem to have much choice.
Perhaps I'll test out the syndic system I haven't yet tried, out of curiosity does a syndic master consume more or less resources to your knowledge than a regular master? The other possibility is that I could setup a VPN between the two and see if that works any better...
I would venture a guess that this is the same situation @0xDEC0DE had and he/she/they took one of the above steps to mitigate it. If that is the case then I'd call this issue closed (as invalid since it seems to be outside of Salt's domain.)
Ok, I will close this guy then. we have seen firewall/proxy issues, and the ZeroMQ guys say that (and we agree) ZeroMQ 3.2 solves many of them. As for the syndic master, a syndic is a bridge between a full master to a higher level, and full, master, they are just as resource intense
I have noticed the same issue on two of our VPS running over openVZ. strace will hang like below. May be there is no hope for some of these OpenVZ setup. We have several others (CentOS5, 6, running on openvz fine). So this is probably some specific setup at host level or kernel issue of openvz server as suspected in this post.
Some details if it helps. Kernel version: 2.6.18-308.8.2.el5.028stab101.1
telnet master [salt-port] works fine (so no basic firewall issue, I suspect)
After salt-minion start, tcpdump shows no packets flowing from minion to master at all
[root@vps01 ~]# salt-call --versions-report Salt: 0.13.0 Python: 2.6.6 (r266:84292, Sep 11 2012, 08:34:23) Jinja2: unknown M2Crypto: 0.20.2 msgpack-python: 0.1.9.final msgpack-pure: not installed pycrypto: 2.0.1 PyYAML: 3.10 PyZMQ: 2.2.0.1
[root@vps01 ~]# strace salt-minion -l debug .. snip ... read(10, "-----BEGIN PUBLIC KEY-----\nMIICI"..., 4096) = 796 read(10, "", 4096) = 0 close(10) = 0 munmap(0x2b575bd05000, 4096) = 0 unlink("/tmp/tmpiDEhKF") = 0 poll([{fd=9, events=POLLIN}], 1, 0) = 1 ([{fd=9, revents=POLLIN}]) read(9, "\1\0\0\0\0\0\0\0", 8) = 8 poll([{fd=9, events=POLLIN}], 1, 0) = 0 (Timeout) poll([{fd=9, events=POLLIN}], 1, 0) = 0 (Timeout) poll([{fd=9, events=POLLIN}], 1, 0) = 0 (Timeout) poll([{fd=9, events=POLLIN}], 1, 60000
-- hangs for long time here and keep looping--- and no traffic flowing (tcpdump on master or minion side shows no packets sent to master)