Skip to content

Commit 20a1ce3

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Delete OVS port on unstack to retain system connectivity"
2 parents 6c35d36 + a0d1b01 commit 20a1ce3

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

lib/neutron-legacy

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,8 @@ function _move_neutron_addresses_route {
802802
local from_intf=$1
803803
local to_intf=$2
804804
local add_ovs_port=$3
805-
local af=$4
805+
local del_ovs_port=$4
806+
local af=$5
806807

807808
if [[ -n "$from_intf" && -n "$to_intf" ]]; then
808809
# Remove the primary IP address from $from_intf and add it to $to_intf,
@@ -816,6 +817,7 @@ function _move_neutron_addresses_route {
816817
local DEFAULT_ROUTE_GW
817818
DEFAULT_ROUTE_GW=$(ip -f $af r | awk "/default.+$from_intf/ { print \$3; exit }")
818819
local ADD_OVS_PORT=""
820+
local DEL_OVS_PORT=""
819821

820822
IP_BRD=$(ip -f $af a s dev $from_intf scope global primary | grep inet | awk '{ print $2, $3, $4; exit }')
821823

@@ -827,13 +829,19 @@ function _move_neutron_addresses_route {
827829
ADD_OVS_PORT="sudo ovs-vsctl --may-exist add-port $to_intf $from_intf"
828830
fi
829831

832+
if [[ "$del_ovs_port" == "True" ]]; then
833+
DEL_OVS_PORT="sudo ovs-vsctl --if-exists del-port $from_intf $to_intf"
834+
fi
835+
830836
if [[ "$IP_BRD" != "" ]]; then
831837
IP_DEL="sudo ip addr del $IP_BRD dev $from_intf"
832838
IP_ADD="sudo ip addr add $IP_BRD dev $to_intf"
833839
IP_UP="sudo ip link set $to_intf up"
834840
fi
835841

836-
$IP_DEL; $IP_ADD; $IP_UP; $ADD_OVS_PORT; $ADD_DEFAULT_ROUTE
842+
# The add/del OVS port calls have to happen either before or
843+
# after the address is moved in order to not leave it orphaned.
844+
$DEL_OVS_PORT; $IP_DEL; $IP_ADD; $IP_UP; $ADD_OVS_PORT; $ADD_DEFAULT_ROUTE
837845
fi
838846
}
839847

@@ -842,14 +850,14 @@ function _move_neutron_addresses_route {
842850
function cleanup_neutron {
843851

844852
if [[ -n "$OVS_PHYSICAL_BRIDGE" ]]; then
845-
_move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False "inet"
853+
_move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False True "inet"
846854

847855
if [[ $(ip -f inet6 a s dev "$OVS_PHYSICAL_BRIDGE" | grep -c 'global') != 0 ]]; then
848856
# ip(8) wants the prefix length when deleting
849857
local v6_gateway
850858
v6_gateway=$(ip -6 a s dev $OVS_PHYSICAL_BRIDGE | grep $IPV6_PUBLIC_NETWORK_GATEWAY | awk '{ print $2 }')
851859
sudo ip -6 addr del $v6_gateway dev $OVS_PHYSICAL_BRIDGE
852-
_move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False "inet6"
860+
_move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False False "inet6"
853861
fi
854862

855863
if is_provider_network && is_ironic_hardware; then
@@ -1044,10 +1052,10 @@ function _configure_neutron_l3_agent {
10441052

10451053
neutron_plugin_configure_l3_agent
10461054

1047-
_move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" True "inet"
1055+
_move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" True False "inet"
10481056

10491057
if [[ $(ip -f inet6 a s dev "$PUBLIC_INTERFACE" | grep -c 'global') != 0 ]]; then
1050-
_move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" False "inet6"
1058+
_move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" False False "inet6"
10511059
fi
10521060
}
10531061

0 commit comments

Comments
 (0)