salt icon indicating copy to clipboard operation
salt copied to clipboard

minions don't re-authenticate in a multi-master setup

Open bernieke opened this issue 12 years ago • 19 comments

In a single-master setup the minions will try to re-authenticate with the master until they succeed.

But in a multi-master setup we observe the following behavior when starting a minion process:

  • if no masters are up, the minion fails to start
  • if not all masters are up, the minion only authenticates with the masters which are up (if for instance you reboot an appliance which hosts both a salt-master and a salt-minion (in multi-master configuration), after reboot you'll notice the master on that appliance can't address its minion unless you wait a few seconds and restart the minion...)

I would expect the minions to behave the same in both situations. (They should try to re-authenticate with all configured masters.)

We use salt as follows:

  • we have multiple loadbalanced frontend appliances, which each run a salt-master
  • the frontend applications use the salt-master to execute states on the minions

Just to place this in context: As the behavior currently stands we need to do the following to make sure everything works ok:

  • we first test.ping all minions
  • if some don't report back, we "normal ping" them
  • if they are online, we try to "regular ssh" restart the minions on them (if they aren't, we fail the command, refusing to execute states as long as not all our minions are up)
  • we then wait a bit, and retry the test.ping
  • once all are reported up (well, authenticated really...), we can execute our states

We would expect only to need to do the first test.ping to make sure they are all up, and then either execute the states, or raise an error if not all were up.

bernieke avatar Oct 30 '14 08:10 bernieke

Hi @bernieke

Against which version of Salt are you observing the behaviour wherein if a minion is configured for MM, it will not start up if no masters can be reached? I have tested this against 2014.7rc6 this morning and I do not see that happening. Instead, I see a minion that's configured for multiple masters start up and wait until those masters come online and connecting to them when they do.

This MM code has had a fair amount of work done on it for 2014.7 so if you haven't tested your setup against one of the RCs, you may find that some (if not all) of your concerns have already been addressed.

cachedout avatar Oct 30 '14 16:10 cachedout

I'm also on 2014.7.0rc6

I've just checked again, since the last time I tried this I wasn't on rc6 yet, but the behavior I described is still there.

What I'm doing (on both appliances simultaneously):

stop salt-minion
stop salt-master
start salt-minion
sleep 15
ps aux|grep salt-minion

The ps will show salt-minion having died.

This is the minion log:

2014-10-30 16:28:58,533 [salt             ][INFO    ] Setting up the Salt Minion "node2"
2014-10-30 16:28:58,534 [salt.utils.process][DEBUG   ] Created pidfile: /var/run/salt-minion.pid
2014-10-30 16:28:58,535 [salt.minion      ][DEBUG   ] MultiMinion PUB socket URI: ipc:///var/run/salt/minion/minion_event_78882aaeb0_pub.ipc
2014-10-30 16:28:58,535 [salt.minion      ][DEBUG   ] MultiMinion PULL socket URI: ipc:///var/run/salt/minion/minion_event_78882aaeb0_pull.ipc
2014-10-30 16:28:58,535 [salt.minion      ][INFO    ] Starting pub socket on ipc:///var/run/salt/minion/minion_event_78882aaeb0_pub.ipc
2014-10-30 16:28:58,535 [salt.minion      ][INFO    ] Starting pull socket on ipc:///var/run/salt/minion/minion_event_78882aaeb0_pull.ipc
2014-10-30 16:28:58,536 [salt.config      ][DEBUG   ] Reading configuration from /etc/salt/minion
2014-10-30 16:28:58,756 [salt.minion      ][DEBUG   ] Attempting to authenticate with the Salt Master at 10.147.128.120
2014-10-30 16:28:58,758 [salt.crypt       ][DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
2014-10-30 16:29:03,811 [salt.minion      ][ERROR   ] Error while bringing up minion for multi-master. Is master at 10.147.128.120 responding?
2014-10-30 16:29:03,812 [salt.config      ][DEBUG   ] Reading configuration from /etc/salt/minion
2014-10-30 16:29:04,051 [salt.minion      ][DEBUG   ] Attempting to authenticate with the Salt Master at 10.147.128.112
2014-10-30 16:29:04,052 [salt.crypt       ][DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem
2014-10-30 16:29:09,109 [salt.minion      ][ERROR   ] Error while bringing up minion for multi-master. Is master at 10.147.128.112 responding?
2014-10-30 16:29:09,110 [salt.minion      ][ERROR   ] Error while bringing up minion for multi-master. All configured masters [10.147.128.120, 10.147.128.112] are not responding!!!
2014-10-30 16:29:09,112 [salt             ][ERROR   ] Error while bringing up minion for multi-master. All configured masters [10.147.128.120, 10.147.128.112] are not responding!!!

My master config:

log_level: debug

And minion config:

master:
  - 10.147.128.112
  - 10.147.128.120

log_level: debug

I'm on ubuntu 14.04

bernieke avatar Oct 30 '14 16:10 bernieke

Note that I've updated the comment above with the correct test script.

bernieke avatar Oct 30 '14 16:10 bernieke

@bernieke - I am able to reproduce this error. We'll get this fixed up!

rallytime avatar Oct 30 '14 20:10 rallytime

The problem was that I wasn't waiting long enough to see the timeout. You are correct. We'll fix this. Thanks!

On Thu, Oct 30, 2014 at 2:00 PM, Nicole Thomas [email protected] wrote:

@bernieke https://github.com/bernieke - I am able to reproduce this error. We'll get this fixed up!

— Reply to this email directly or view it on GitHub https://github.com/saltstack/salt/issues/17032#issuecomment-61159824.

cachedout avatar Oct 30 '14 20:10 cachedout

Also getting this same problem;

root@db1:~# salt-minion  --version
salt-minion 2014.1.13 (Hydrogen)

foxx avatar Nov 04 '14 19:11 foxx

Both problems still exist on 2014.7.0

Is there an estimate to which revision this will be addressed in?

bernieke avatar Nov 17 '14 13:11 bernieke

@bernieke I can see where this would make multi-master exceedingly difficult to maintain in a production environment so I'm going to upgrade this to high-severity so we can hopefully get some more eyes on a possible fix. There is no ETA at present, but obviously, bugs are usually addressed by severity so this should bump it up substantially in the queue. :]

cachedout avatar Nov 24 '14 18:11 cachedout

How's this bug's resolution looking? I think I am hitting this too.

DaveQB avatar Mar 04 '15 15:03 DaveQB

Is this related to issue #20197 ? These two issues could be tied together

DaveQB avatar Mar 09 '15 10:03 DaveQB

I believe we have resolved this issue in the next release of 2014.7 and in 2015.2. I am able to see minions reconnecting to masters after a master goes down. By default, the retry time is 60s.

cachedout avatar Mar 25 '15 21:03 cachedout

Hello!

I was able to reproduce this issue with the latest HEAD from the 2014.7 branch.

If minion is configured with 2 saltmasters:

  • stop masters and minion
  • start master 1 only
  • start minion
  • start master 2
  • try to do test.ping from both masters: it will work from master 1 but not work from master 2 until you restart minion again so it will be able to re-auth with master 2.

vakulich avatar Apr 13 '15 11:04 vakulich

I've just tried this on 2014.7.5, and the problem still exists.

Both the behavior where minions fail to start when no masters are running, and the behavior where minions won't listen to a master which isn't up when the minion was first started.

bernieke avatar Apr 24 '15 12:04 bernieke

Thanks for the updates. I am seeing the same thing. If all masters are up and running when the minion starts, and then later one of the masters goes down, I am seeing the minions reconnect. But you're right, if the master isn't up when the minion first starts and tries to connect, the behavior is still the same/broken.

rallytime avatar Apr 24 '15 14:04 rallytime

Having this issue on 2014.7.1. Tried restarting the masters and restarting the minion. Same error. Any recommended workarounds?

[root@ip-xx-yy-zz-aa salt]# salt-minion -l debug [DEBUG   ] Reading configuration from /etc/salt/minion [DEBUG   ] Including configuration from '/etc/salt/minion.d/masters.conf' [DEBUG   ] Reading configuration from /etc/salt/minion.d/masters.conf [DEBUG   ] Including configuration from '/etc/salt/minion.d/startup.conf' [DEBUG   ] Reading configuration from /etc/salt/minion.d/startup.conf [DEBUG   ] Using cached minion ID from /etc/salt/minion_id: i-wwxxyyzz [DEBUG   ] Configuration file path: /etc/salt/minion [INFO    ] Setting up the Salt Minion "i-wwxxyyzz" [DEBUG   ] Created pidfile: /var/run/salt-minion.pid [DEBUG   ] MultiMinion PUB socket URI: ipc:///var/run/salt/minion/minion_event_6ce01a1300_pub.ipc [DEBUG   ] MultiMinion PULL socket URI: ipc:///var/run/salt/minion/minion_event_6ce01a1300_pull.ipc [INFO    ] Starting pub socket on ipc:///var/run/salt/minion/minion_event_6ce01a1300_pub.ipc [INFO    ] Starting pull socket on ipc:///var/run/salt/minion/minion_event_6ce01a1300_pull.ipc [DEBUG   ] Reading configuration from /etc/salt/minion [DEBUG   ] Including configuration from '/etc/salt/minion.d/masters.conf' [DEBUG   ] Reading configuration from /etc/salt/minion.d/masters.conf [DEBUG   ] Including configuration from '/etc/salt/minion.d/startup.conf' [DEBUG   ] Reading configuration from /etc/salt/minion.d/startup.conf [DEBUG   ] Attempting to authenticate with the Salt Master at xx.yy.zz.aa [DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem [ERROR   ] Error while bringing up minion for multi-master. Is master at xx.yy.zz.aa responding? [DEBUG   ] Reading configuration from /etc/salt/minion [DEBUG   ] Including configuration from '/etc/salt/minion.d/masters.conf' [DEBUG   ] Reading configuration from /etc/salt/minion.d/masters.conf [DEBUG   ] Including configuration from '/etc/salt/minion.d/startup.conf' [DEBUG   ] Reading configuration from /etc/salt/minion.d/startup.conf [DEBUG   ] Attempting to authenticate with the Salt Master at yy.zz.aa.bb [DEBUG   ] Loaded minion key: /etc/salt/pki/minion/minion.pem [ERROR   ] Error while bringing up minion for multi-master. Is master at yy.zz.aa.bb responding? [ERROR   ] Error while bringing up minion for multi-master. All configured masters [xx.yy.zz.aa, yy.zz.aa.bb] are not responding!!! [ERROR   ] Error while bringing up minion for multi-master. All configured masters [xx.yy.zz.aa, yy.zz.aa.bb] are not responding!!!

charleshbaker avatar May 12 '15 19:05 charleshbaker

Just adding our update on this. We've just upgraded to 2014.7.5 and found about 50% of our minions "disappeared" much like the result of upgrading to 2014.7.1

I've created an ssh script to loop through all the minion machines and restart salt (glad AWS allows easy look up of all servers IP addresses).

DaveQB avatar May 15 '15 01:05 DaveQB

I have just tested this on a soon-to-be released/potential 2015.5.1. It would appear that most of the original bugs/concerns are fixed. However, some of the things that are fixed are traded for another problem in a new bug, #21744. I wanted to take a moment to explain the differences in behavior that I am seeing from the 2014.7 releases to the 2015.5 releases in my testing.

Basically what I am seeing (on 2015.5.1) is this:

Expected (and Good) Behavior:

  • Start both masters, start minions, command execution/returns/etc happen as expected.
  • If a master goes down, the other master(s) can communicate with the minions just fine.
  • Masters can come back up and continue communicating with the minions just fine as well.
  • Even if all masters go down (but the minions stay up), the masters can still communicate with the minions when the master(s) come back online.

Improvements in Minion Re-Authenticating with Master:

  • Before 2015.5.0, if you started the minion and one or more masters were down, the minion would never authenticate with the masters that were down without restarting the minion.
  • Now, if the minion starts and one or more masters is down, the minion will continue to try to authenticate with the down master(s) until all masters are up. For example, if the minion starts and no masters are up, the minion will continue to try to connect with each master. I believe this resolves the original issue(s) here, but unfortunately we are trading that behavior for the problem listed in #21744.

Caveat/Problems because of #21744:

  • Because the minion blocks on authenticating with all masters on minion start, this means if one master is down, you cannot command the minion from any master.
  • This behavior is very far from ideal and we definitely need to get it fixed. It should be noted that once the necessary master processes have been started again and the minion can now initially authenticate, masters can go down and come back up as needed as described above.
  • I realize that this behavior is still very similar to the original report. (Masters need to be up when the minion starts.) The difference here is that the master process can be started instead of finding lost minions and starting the minion process.

rallytime avatar May 21 '15 19:05 rallytime

I've noticed that adding "auth_safemode: true" to the minion config gets 2014.7.0 the same behavior as 2015 currently has per ticket #21744

As described in that ticket I've gone and hacked up a fix for us (on top of 2014.7.0), which combined with auth_safemode gives us the behavior we need. (Masters and minions can now start/restart with any of them running/stopped, and everything just works the way you would expect.)

I've set auth_timeout and random_reauth_delay to 15 seconds, and auth_tries to 1. This, combined with a 120 second timeout in the master config, makes it so any call executed will actually come through on any running minion, even if it needs to reauthenticate. (I've tried using ping_interval to avoid this problem, but that didn't do anything for me. Possibly another multimaster bug?)

bernieke avatar Jun 12 '15 14:06 bernieke

Seems these problems are all fixed in 2015.8, thanks to the rewrite using tornado.

bernieke avatar Aug 11 '15 12:08 bernieke