From f89936e1ac568a9465f69a7c941803b6b575b0cd Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Thu, 24 Sep 2015 13:30:30 -0700 Subject: [PATCH] Setup multinode interfaces on singlenode n-net Because nova net takes over eth0 by default and slurps it into br100 there are corner cases where this will break funny existing network setups. One example is where the VMs default route is not within the network assigned to eth0. Work around this by using the overlay networking with nova net always. We will create an ovs gre bridge that is a bridge to nowhere. But nova net can connect to that and not break the existing networking. Change-Id: Ia8af343b17e05191e47dc7f3969aeaf19a443da6 --- devstack-vm-gate.sh | 66 ++++++++++++++++++++++++++++++++------------- functions.sh | 14 ++++++++-- 2 files changed, 59 insertions(+), 21 deletions(-) diff --git a/devstack-vm-gate.sh b/devstack-vm-gate.sh index f83b036f..568db23d 100755 --- a/devstack-vm-gate.sh +++ b/devstack-vm-gate.sh @@ -60,6 +60,26 @@ function setup_ssh { -a "src=/etc/nodepool/id_rsa dest='$path/id_rsa' mode=0400" } +function setup_nova_net_networking { + local localrc=$1 + local primary_node=$2 + shift 2 + local sub_nodes=$@ + # We always setup multinode connectivity to work around an + # issue with nova net configuring br100 to take over eth0 + # by default. + # TODO (clarkb): figure out how to make bridge setup sane with ansible. + ovs_gre_bridge "br_pub" $primary_node "True" 1 \ + $FLOATING_HOST_PREFIX $FLOATING_HOST_MASK \ + $sub_nodes + ovs_gre_bridge "br_flat" $primary_node "False" 128 \ + $sub_nodes + cat <>"$localrc" +FLAT_INTERFACE=br_flat +PUBLIC_INTERFACE=br_pub +EOF +} + function setup_multinode_connectivity { local mode=${1:-"devstack"} # Multinode setup variables: @@ -86,29 +106,24 @@ function setup_multinode_connectivity { set -x # for now enabling debug and do not turn it off setup_localrc $old_or_new "$sub_localrc" "sub" - PRIMARY_NODE=`cat /etc/nodepool/primary_node_private` - SUB_NODES=`cat /etc/nodepool/sub_nodes_private` + local primary_node + primary_node=$(cat /etc/nodepool/primary_node_private) + local sub_nodes + sub_nodes=$(cat /etc/nodepool/sub_nodes_private) if [[ "$DEVSTACK_GATE_NEUTRON" -ne '1' ]]; then - # TODO (clarkb): figure out how to make bridge setup sane with ansible. - ovs_gre_bridge "br_pub" $PRIMARY_NODE "True" 1 \ - $FLOATING_HOST_PREFIX $FLOATING_HOST_MASK \ - $SUB_NODES - ovs_gre_bridge "br_flat" $PRIMARY_NODE "False" 128 \ - $SUB_NODES + setup_nova_net_networking $localrc $primary_node $sub_nodes cat <>"$sub_localrc" FLAT_INTERFACE=br_flat PUBLIC_INTERFACE=br_pub MULTI_HOST=True EOF cat <>"$localrc" -FLAT_INTERFACE=br_flat -PUBLIC_INTERFACE=br_pub MULTI_HOST=True EOF elif [[ "$DEVSTACK_GATE_NEUTRON_DVR" -eq '1' ]]; then - ovs_gre_bridge "br-ex" $PRIMARY_NODE "True" 1 \ + ovs_gre_bridge "br-ex" $primary_node "True" 1 \ $FLOATING_HOST_PREFIX $FLOATING_HOST_MASK \ - $SUB_NODES + $sub_nodes fi echo "Preparing cross node connectivity" @@ -116,7 +131,7 @@ EOF setup_ssh ~root/.ssh # TODO (clarkb) ansiblify the /etc/hosts and known_hosts changes # set up ssh_known_hosts by IP and /etc/hosts - for NODE in $SUB_NODES; do + for NODE in $sub_nodes; do ssh-keyscan $NODE >> /tmp/tmp_ssh_known_hosts echo $NODE `remote_command $NODE hostname | tr -d '\r'` >> /tmp/tmp_hosts done @@ -132,7 +147,7 @@ EOF $ANSIBLE all --sudo -f 5 -i "$WORKSPACE/inventory" -m copy \ -a "src=/tmp/tmp_ssh_known_hosts dest=/etc/ssh/ssh_known_hosts mode=0444" - for NODE in $SUB_NODES; do + for NODE in $sub_nodes; do remote_copy_file /tmp/tmp_hosts $NODE:/tmp/tmp_hosts remote_command $NODE "cat /tmp/tmp_hosts | sudo tee --append /etc/hosts > /dev/null" cp $sub_localrc /tmp/tmp_sub_localrc @@ -142,6 +157,18 @@ EOF done } +function setup_networking { + local mode=${1:-"devstack"} + # Neutron in single node setups does not need any special + # sauce to function. + if [[ "$DEVSTACK_GATE_TOPOLOGY" != "multinode" ]] && \ + [[ "$DEVSTACK_GATE_NEUTRON" -ne '1' ]]; then + setup_nova_net_networking "localrc" "127.0.0.1" + elif [[ "$DEVSTACK_GATE_TOPOLOGY" == "multinode" ]]; then + setup_multinode_connectivity $mode + fi +} + function setup_localrc { local localrc_oldnew=$1; local localrc_file=$2 @@ -559,8 +586,6 @@ EOF # get this in our base config cp local.conf $BASE/old/devstack - setup_multinode_connectivity "grenade" - # build the post-stack.sh config, this will be run as stack user so no sudo required cat > $BASE/new/grenade/post-stack.sh <> local.conf - setup_multinode_connectivity fi + + setup_networking + # Make the workspace owned by the stack user # It is not clear if the ansible file module can do this for us $ANSIBLE all --sudo -f 5 -i "$WORKSPACE/inventory" -m shell \ diff --git a/functions.sh b/functions.sh index 7f57b584..5df404b8 100644 --- a/functions.sh +++ b/functions.sh @@ -927,9 +927,19 @@ function enable_netconsole { # http://www.yet.org/2014/09/openvswitch-troubleshooting/ # function ovs_gre_bridge { + if is_fedora; then + local ovs_package='openvswitch' + local ovs_service='openvswitch' + elif uses_debs; then + local ovs_package='openvswitch-switch' + local ovs_service='openvswitch-switch' + else + echo "Unsupported platform, can't determine ntp service" + exit 1 + fi local install_ovs_deps="source $BASE/new/devstack/functions-common; \ - install_package openvswitch-switch; \ - restart_service openvswitch-switch" + install_package ${ovs_package}; \ + restart_service ${ovs_service}" local mtu=1450 local bridge_name=$1 local host_ip=$2