From 214feefd1324938aa08ef2cdf46fcecc2d2b4a3c Mon Sep 17 00:00:00 2001 From: Sangeet Gupta Date: Thu, 26 Mar 2020 11:44:14 -0500 Subject: [PATCH] Nova: Update compute start script for console [0] added route command to identify multiple default routes. In some deployments, route command is not available which set the client_interface value incorrectly. In this case VNC clinet tries to connect to default host 127.0.0.1 and fails. [0] https://review.opendev.org/#/c/696187 Change-Id: I4a936af053114988e0b70048e276a71833c5638e --- nova/templates/bin/_nova-console-compute-init.sh.tpl | 8 ++++++-- nova/templates/bin/_nova-console-proxy-init.sh.tpl | 8 ++++++-- 2 files changed, 12 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 212140f335..e672582793 100644 --- a/nova/templates/bin/_nova-console-compute-init.sh.tpl +++ b/nova/templates/bin/_nova-console-compute-init.sh.tpl @@ -32,8 +32,12 @@ fi if [ -z "${client_address}" ] ; then if [ -z "${client_interface}" ] ; then - # 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 }') + if [ -x "$(command -v route)" ] ; then + # 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 }') + else + client_interface=$(ip r | grep default | awk '{print $5}') + fi 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 153e60d4b7..2b7e543e74 100644 --- a/nova/templates/bin/_nova-console-proxy-init.sh.tpl +++ b/nova/templates/bin/_nova-console-proxy-init.sh.tpl @@ -32,8 +32,12 @@ fi if [ -z "${client_address}" ] ; then if [ -z "${client_interface}" ] ; then - # 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 }') + if [ -x "$(command -v route)" ] ; then + # 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 }') + else + client_interface=$(ip r | grep default | awk '{print $5}') + fi fi # determine client ip dynamically based on interface provided