Make keepalived initialization more predictable
This prevents forcing keepalived to renegotiate roles between amps more times than necessary. Keepalived is already running at the point that we do our initial "amp start" command, so if we actually force a restart it loses its state and has to renegotiate. I would consider the fact that this works without issue right now "very good luck". Let's make this more sane, and only reload if that's what we need to do. Change-Id: Ie920bba9b2d718c59c6ce00c0f013058ed2634bb
This commit is contained in:
parent
06bf5c58d5
commit
d4474e8943
@ -128,6 +128,20 @@ class Keepalived(object):
|
||||
message='Invalid Request',
|
||||
details="Unknown action: {0}".format(action)), status=400)
|
||||
|
||||
if action == consts.AMP_ACTION_START:
|
||||
keepalived_pid_path = util.keepalived_pid_path()
|
||||
try:
|
||||
# Is there a pid file for keepalived?
|
||||
with open(keepalived_pid_path, 'r') as pid_file:
|
||||
pid = int(pid_file.readline())
|
||||
os.kill(pid, 0)
|
||||
|
||||
# If we got here, it means the keepalived process is running.
|
||||
# We should reload it instead of trying to start it again.
|
||||
action = consts.AMP_ACTION_RELOAD
|
||||
except (IOError, OSError):
|
||||
pass
|
||||
|
||||
cmd = ("/usr/sbin/service octavia-keepalived {action}".format(
|
||||
action=action))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user