From 0e75bf821a71980f1336196831d1f2aaeb831db0 Mon Sep 17 00:00:00 2001 From: Tom Barron Date: Tue, 16 Jul 2019 14:55:21 -0400 Subject: [PATCH] Conditionally restore default route in setup_ipv6 Restoring the default IPv6 route is not needed in CI and fails when there are multiple defaults, but it is useful in local devstacks where multiple default routes are not typical. Add a variable in settings and use it to make this behavior conditional and set it to False for the lvm job. Closes-bug: #1836788 Change-Id: Id73de8100509ec5935641f5f35f93f482d108bcd (cherry picked from commit 70e908344dd4db81652264a2de2c04ce9666bb46) (cherry picked from commit 99c0a110920910bfd379d544e7085daca90b1132) (cherry picked from commit 682d6b6ee17e8abb4038ca304bee839463424838) --- contrib/ci/pre_test_hook.sh | 1 + devstack/plugin.sh | 18 +++++++++++++----- devstack/settings | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/contrib/ci/pre_test_hook.sh b/contrib/ci/pre_test_hook.sh index 3ded64c7f1..00a7bbe8e2 100755 --- a/contrib/ci/pre_test_hook.sh +++ b/contrib/ci/pre_test_hook.sh @@ -189,6 +189,7 @@ if [[ "$MANILA_SETUP_IPV6" == True ]]; then # regular Neutron DevStack configuration. echo "NEUTRON_CREATE_INITIAL_NETWORKS=False" >> $localconf echo "IP_VERSION=4+6" >> $localconf + echo "MANILA_RESTORE_IPV6_DEFAULT_ROUTE=False" >> $localconf fi if [[ "$DRIVER" == "generic"* ]]; then diff --git a/devstack/plugin.sh b/devstack/plugin.sh index db0a9bfe16..7c79c93083 100755 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -955,8 +955,12 @@ function install_libraries { function setup_ipv6 { - # save IPv6 default route to add back later after enabling forwarding - local default_route=$(ip -6 route | grep default | cut -d ' ' -f1,2,3,4,5) + # This will fail with multiple default routes and is not needed in CI + # but may be useful when developing with devstack locally + if [ $(trueorfalse False MANILA_RESTORE_IPV6_DEFAULT_ROUTE) == True ]; then + # save IPv6 default route to add back later after enabling forwarding + local default_route=$(ip -6 route | grep default | cut -d ' ' -f1,2,3,4,5) + fi # make sure those system values are set sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0 @@ -1055,9 +1059,13 @@ function setup_ipv6 { sudo systemctl restart bgpd fi - # add default IPv6 route back - if ! [[ -z $default_route ]]; then - sudo ip -6 route add $default_route + # This will fail with mutltiple default routes and is not needed in CI + # but may be useful when developing with devstack locally + if [ $(trueorfalse False MANILA_RESTORE_IPV6_DEFAULT_ROUTE) == True ]; then + # add default IPv6 route back + if ! [[ -z $default_route ]]; then + sudo ip -6 route add $default_route + fi fi } diff --git a/devstack/settings b/devstack/settings index fb1ed0d551..a2a0e7a43d 100644 --- a/devstack/settings +++ b/devstack/settings @@ -201,6 +201,7 @@ MANILA_DATA_COPY_CHECK_HASH=${MANILA_DATA_COPY_CHECK_HASH:=True} # Manila IPv6 Setup flag MANILA_SETUP_IPV6=${MANILA_SETUP_IPV6:=False} +MANILA_RESTORE_IPV6_DEFAULT_ROUTE=${MANILA_RESTORE_IPV6_DEFAULT_ROUTE:=True} # Enable manila services # ----------------------