corrupt keys in Helium
I am seeing corrupt keys in helium for lots of minions, as evidenced in the salt-master log file:
[ERROR ] Corrupt public key "/etc/salt/pki/master/minions/somehost.somedomain.com": no start line
Salt: 2014.7.0
Python: 2.7.8 (default, Nov 25 2014, 07:25:02)
Jinja2: 2.7.3
M2Crypto: 0.22
msgpack-python: 0.4.2
msgpack-pure: Not Installed
pycrypto: 2.6.1
libnacl: 1.4.0
PyYAML: 3.11
ioflo: 1.0.2
PyZMQ: 14.4.1
RAET: 0.3.8
ZMQ: 4.0.4
Mako: 1.0.0
Running master in open mode and attempting to delete all the corrupt keys on the minions and recreate them via the below commands to see if this clears it up. Anyone know if this is an artefact of old hydrogen keys not playing nice with helium, or a bug with helium key handling in general? In at least one case this appears to have crashed the master daemon.
grep Corrupt /var/log/salt/master.badkeys | awk '{print $9}' | cut -d '"' -f 2 | cut -d '/' -f 7 | sort |uniq > /tmp/corrupt-keys.txt
for n in cat /tmp/corrupt-keys.txt; do ssh -o BatchMode=yes $n "/etc/init.d/salt-minion stop; rm -rf /etc/salt/minion?* /etc/salt/pki; /etc/init.d/salt-minion restart"; done
I see this too. The minions that had this problem were all upgraded 2014.1 -> 2014.7. For now we are going back to 2014.1. Therefore, I won't be able to test anything, but a "me too" for what it's worth.
We are on Debian Wheezy, so relevant versions: Python: 2.7.3 (default, Mar 13 2014, 11:03:55) Jinja2: 2.6 M2Crypto: 0.21.1 msgpack-python: 0.1.10 msgpack-pure: Not Installed pycrypto: 2.6 PyYAML: 3.10 PyZMQ: 13.1.0 ZMQ: 3.2.3
Hrm that isn't good. We'll take a look. Do either of you have an example of one of the public keys that has been corrupted?
I have identified 500 keys so far that are bad, and am removing and regenerating them. I believe these were all upgraded from Hydrogen->Helium but am not 100% certain. I suspect coping with 500 bad keys was too much for the master daemon, causing it to give up the ghost. I've been aggressive in getting rid of these, but there are still a few surfacing from time to time.
Here's one that is still around: 2014-12-17 14:13:36,252 [salt.master ][ERROR ] Corrupt public key "/etc/salt/pki/master/minions/somehost.somedomain.com": no start line
-----BEGIN PUBLIC KEY----- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA2TVoSVChB7cUCx6nzbsV gHCmg087GGldffCiH9qE0qTa2reHhtNlGRSb/oUf445dVpvHYlB/T8p/0BKApdxU MdIFhBCajTpYVBZVhTZsr+RujN+rlKRHWIXl3mYPVE6x9gYEVX2ALNDpW+v9VRB8 +xtReScYr35ZckdXJuJ1hFnnPpDPpyiUChu6xkQp5S+s4fNfGrD0B1WDKfrGLXYS ItW95060xLUvOpcS56ySJfNG/Vn+VEvzFZRemN7l9eo0z83IAQiXSOYQvsS2tbrZ MOnCs5adp/MdHxEEJCtXyoe0aq+nEY9TmhwYJMfA/zADi5uL5Si9xGSzZHpyrlO7 IHirfkROZQ2+50lkyCRTs5gUXzqLibY/VaRZfgxiDh+J9v+O8Kf2alu39vEY8EhF JCb6fkliJkjbBTPnlF4q2xH7hnjSfBHZPV390s5kwFQvDYOPM9GKkl0oBMkFUUb/ Tf2wRXe8nYOy7bwNyQvmr2r3ghWeYMK9EuryAJ9e2Tw0Uqz2PemwFEFzZhTnNsmR RySKlGnZCczmJl32c6H4hj3Gw2TaIGFnUpdHFMKjLgZSeF0PbOv2I4G70AvBmRP5 Oh+UI6SvE7eh6gPvZo8PVqRpQOrmbnb68EaZOOuznLBcB2o9y0FAWNgHPKskr2lv E2Veliygg7EgToSg9eeKKIUCAwEAAQ== -----END PUBLIC KEY-----
I see no obvious problem with this key. Just to confirm, although I cut and pasted the above directly from the minion, the master sees the exact same thing (/etc/salt/pki/master/minions/somehost.somedomain.com):
-----BEGIN PUBLIC KEY----- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA2TVoSVChB7cUCx6nzbsV gHCmg087GGldffCiH9qE0qTa2reHhtNlGRSb/oUf445dVpvHYlB/T8p/0BKApdxU MdIFhBCajTpYVBZVhTZsr+RujN+rlKRHWIXl3mYPVE6x9gYEVX2ALNDpW+v9VRB8 +xtReScYr35ZckdXJuJ1hFnnPpDPpyiUChu6xkQp5S+s4fNfGrD0B1WDKfrGLXYS ItW95060xLUvOpcS56ySJfNG/Vn+VEvzFZRemN7l9eo0z83IAQiXSOYQvsS2tbrZ MOnCs5adp/MdHxEEJCtXyoe0aq+nEY9TmhwYJMfA/zADi5uL5Si9xGSzZHpyrlO7 IHirfkROZQ2+50lkyCRTs5gUXzqLibY/VaRZfgxiDh+J9v+O8Kf2alu39vEY8EhF JCb6fkliJkjbBTPnlF4q2xH7hnjSfBHZPV390s5kwFQvDYOPM9GKkl0oBMkFUUb/ Tf2wRXe8nYOy7bwNyQvmr2r3ghWeYMK9EuryAJ9e2Tw0Uqz2PemwFEFzZhTnNsmR RySKlGnZCczmJl32c6H4hj3Gw2TaIGFnUpdHFMKjLgZSeF0PbOv2I4G70AvBmRP5 Oh+UI6SvE7eh6gPvZo8PVqRpQOrmbnb68EaZOOuznLBcB2o9y0FAWNgHPKskr2lv E2Veliygg7EgToSg9eeKKIUCAwEAAQ== -----END PUBLIC KEY-----
this is worrying. In at least one case I've seen a key I generated with Helium come back a little while later as corrupt, and had to remove it again. So this may not be limited to Hydrogen->Helium upgrades
also starting to see these crop up., may be related
2014-12-17 15:03:44,126 [salt.payload ][CRITICAL] Could not deserialize msgpack message: In an attempt to keep Salt running, returning an empty dict.This often happens when trying to read a file not in binary mode.Please open an issue and include the following error: Unpack failed: error = 0
Note that is is a multi-master environment (not that that should make any difference)
715 minions unreachable this morning due to this issue (up from 647 yesterday). Deleting keys only seems to work for an hour or two at best...
I rolled my dev environment back to 2014.1.x and it's stopped complaining (without me doing anything to the keys).
That confirms my suspicion that the keys are fine and the problem is somewhere in Helium
Thank you all for updating this issue. This is all very useful to have and will help with the debugging process.
I am also seeing this issue (both master and minions are at 2014.7.0 and have always been at this version).
We have a different use case which may be easier to debug as it is reproduced daily in Continuous Deployment job.
We have a baked image (qcow2) and we rm -rf /etc/salt/pki/ before we save the image. When we boot that image, we again rm -rf /etc/salt/pki just to be safe and then start the minion (through cloud-init script).
In the Continuous Deployment job, we first create a new Salt master in Open Mode and then start multiple VMs using the baked image and we are seeing multiple VMs show "Corrupt public key" issue - say 2 to 3 VMs out of 10. VMs are started sequentially. Reactor is used to trigger highstate on the minion on minion start event. Master and all minions are in debug mode so there are lots of logs but no smoking gun that I can identify.
Salt master log shows: 2015-01-02 10:58:57,642 [salt.master ][INFO ] Clear payload received with command _auth 2015-01-02 10:58:57,643 [salt.master ][INFO ] Authentication request from hostname-redacted 2015-01-02 10:58:57,644 [salt.master ][INFO ] Clear payload received with command _auth 2015-01-02 10:58:57,644 [salt.master ][INFO ] Authentication request from hostname-redacted 2015-01-02 10:58:57,645 [salt.master ][INFO ] Authentication accepted from hostname-redacted 2015-01-02 10:58:57,643 [salt.master ][INFO ] Authentication accepted from hostname-redacted 2015-01-02 10:58:57,646 [salt.master ][ERROR ] Corrupt public key "/etc/salt/pki/master/minions/hostname-redacted": no start line 2015-01-02 10:58:57,696 [salt.master ][INFO ] Clear payload received with command _auth
Corresponding minion on "hostname-redacted" log shows: 2015-01-02 10:58:57,141 [salt.crypt ][CRITICAL] The Salt Master has rejected this minion's public key! To repair this issue, delete the public key for this minion on the Salt Master and restart this minion. Or restart the Salt Master in open mode to clean out the keys. The Salt Minion will now exit.
Remediation: Sometimes we have to just restart salt-minion. In this case, CRITICAL error shown above is the only event in minion log, even the minion start lines - like "Setting up the Salt Minion" - are absent.
Sometimes, it seems, the problem is auto-corrected through subsequent salt-minion -> salt-master auth requests (both master and minion logs show continuous log events related to auth). Only thing we have to do then is to issue state.highstate as the Reactor fired state.highstate event never happened. In this case, minion logs look normal starting with "Setting up the Salt Minion" chatter followed by CRITICAL line and then immediately (same second or next second) followed by lines like "Decrypting the current master AES key"
Let me know if you need more information.
Some similarities I see to our setup... Open mode and reactor triggered highstate.
We are also running in open mode, to handle key changes through the upgrade from Hydrogen to Helium. I am currently on vacation but can check this out later next week when I'm back at work, but in the meantime, is anyone seeing this issue who ISN'T running in open mode?
On Fri, Jan 2, 2015 at 9:19 PM, Brian Jackson [email protected] wrote:
Some similarities I see to our setup... Open mode and reactor triggered highstate.
— Reply to this email directly or view it on GitHub https://github.com/saltstack/salt/issues/19061#issuecomment-68581321.
I have been running several hours with open mode set to false and have not seen this issue since making this change, so this particular bug appears related to open mode. HOWEVER, I am now seeing issue #18322, so I wonder if the two aren't related at a deeper level.
I think I see what's happening here. In open_mode, the public key is getting written out on every single auth.
If you get multiple auths at the same time, the first caller will be reading the public key while the second caller is re-writing it. I'll have a fix here shortly.
@smithjm or @iggy Can either of you test that fix to see if it resolves the problem for you?
I had to roll back to 2014.1.x. If I get some time this weekend (and nobody beats me to it), I'll try to test it.
@iggy Many thanks!
I tested this briefly the other day. Not long enough to say the bug is definitely fixed (it wasn't super easy to reproduce in the first place), but long enough that I didn't see it crop up and I didn't see any other issues.
@iggy Sounds good. If you don't mind, I'm going to go ahead and close this issue then. If it crops back up, please drop a note here and we'll definitely re-open it. Thanks!
In which version the fix is available? It's not mentioned in http://docs.saltstack.com/en/latest/topics/releases/2014.7.1.html