Set explicit route for VIPs

When VIPs are moved around explicit route for each VIP is
set to make sure that connections opened from local node to VIP
don't use VIP as source address - if VIP is used as source address
and is moved away then connections are stalled.

This explicit routes are removed when VIPs are moved to another node.

Closes-Bug: 1376200
Change-Id: Ie5d55fbe33231519015b313b1f9210ac3614266e
This commit is contained in:
Jan Provaznik 2014-11-19 15:24:46 +01:00
parent c84d616eac
commit 815a3b3b77
3 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,30 @@
#!/bin/bash
# A simple script triggered by keepalived when VIPs are moved
# around. When VIPs are moved to this node, explicit route for
# each VIP is added - this assures that any connection to VIP
# will use by default local-ipv4 as source address. Without this
# explicit route VIP address is used which causes issues when VIP
# moved to another node.
# https://bugs.launchpad.net/tripleo/+bug/1376200
#
# When VIP is moved from this node, this explicit route is removed
# to allow proper routing from this node to new VIP node.
set -eu
logger "Started $0 $@"
PATH="$PATH:/bin:/sbin"
LOCAL_IP=$(os-apply-config --key local-ipv4 --type netaddress)
if [ "$3" = "MASTER" ]; then
for ip in $(cat /etc/keepalived/virtual_ips); do
logger "adding explicit route for $ip"
ip ro replace local $ip dev lo src $LOCAL_IP
done
else
for ip in $(cat /etc/keepalived/virtual_ips); do
logger "removing explicit route for $ip"
ip ro del local $ip
done
fi

View File

@ -54,5 +54,6 @@ vrrp_instance VI_1 {
track_script {
chk_haproxy
}
notify /usr/local/bin/keepalived_vip_change.sh
}
{{/virtual_interfaces}}

View File

@ -0,0 +1,3 @@
{{#virtual_ips}}
{{ip}}
{{/virtual_ips}}