From b4248a51b69cc106debabffd71e58611bc7b553c Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Tue, 26 Nov 2019 15:02:46 -0600 Subject: [PATCH] Nova: Update compute start script to accomodate multiple default routes This PS udpates the nova compute start script to account for cases where there may be multiple default routes to the outside world. Change-Id: Ibd051c2577a0ab67aa2a5284fc9ccab799c28953 Signed-off-by: Pete Birley --- nova/templates/bin/_nova-console-compute-init.sh.tpl | 4 ++-- nova/templates/bin/_nova-console-proxy-init.sh.tpl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nova/templates/bin/_nova-console-compute-init.sh.tpl b/nova/templates/bin/_nova-console-compute-init.sh.tpl index aa94ca118a..212140f335 100644 --- a/nova/templates/bin/_nova-console-compute-init.sh.tpl +++ b/nova/templates/bin/_nova-console-compute-init.sh.tpl @@ -32,8 +32,8 @@ fi if [ -z "${client_address}" ] ; then if [ -z "${client_interface}" ] ; then - # search for interface with default routing - client_interface=$(ip r | grep default | awk '{print $5}') + # search for interface with default routing, if multiple default routes exist then select the one with the lowest metric. + client_interface=$(route -n | awk '/^0.0.0.0/ { print $5 " " $NF }' | sort | awk '{ print $NF; exit }') fi # determine client ip dynamically based on interface provided diff --git a/nova/templates/bin/_nova-console-proxy-init.sh.tpl b/nova/templates/bin/_nova-console-proxy-init.sh.tpl index 9bed70dcbf..153e60d4b7 100644 --- a/nova/templates/bin/_nova-console-proxy-init.sh.tpl +++ b/nova/templates/bin/_nova-console-proxy-init.sh.tpl @@ -32,8 +32,8 @@ fi if [ -z "${client_address}" ] ; then if [ -z "${client_interface}" ] ; then - # search for interface with default routing - client_interface=$(ip r | grep default | awk '{print $5}') + # search for interface with default routing, if multiple default routes exist then select the one with the lowest metric. + client_interface=$(route -n | awk '/^0.0.0.0/ { print $5 " " $NF }' | sort | awk '{ print $NF; exit }') fi # determine client ip dynamically based on interface provided