Configure console proxy ports in nova_cellN.conf
We're able to run multiple cells in devstack by setting the variable
NOVA_NUM_CELLS in the devstack local.conf. Since we run console
proxies per cell, we will start two console proxies if
NOVA_NUM_CELLS=2. However, we've not been configuring the console
proxy ports in the nova_cellN.conf files, so an attempt to start
more than one will result in a port conflict and failure to start
the subsequent console proxy services with error:
ERROR nova error: [Errno 98] Address already in use
This adds configuration of the console proxy ports based on an offset
while looping across NOVA_NUM_CELLS. The base port values are taken
from the config option defaults in the nova code: nova/conf/vnc.py,
nova/conf/spice.py, and nova/conf/serial_console.py.
Closes-Bug: #1822873
Change-Id: I8934d0b9392f2976347391c8a650ad260f337762
diff --git a/lib/nova b/lib/nova
index dee798c..1b5132b 100644
--- a/lib/nova
+++ b/lib/nova
@@ -607,8 +607,10 @@
else
for i in $(seq 1 $NOVA_NUM_CELLS); do
local conf
+ local offset
conf=$(conductor_conf $i)
- configure_console_proxies $conf
+ offset=$((i - 1))
+ configure_console_proxies $conf $offset
done
fi
}
@@ -678,10 +680,17 @@
function configure_console_proxies {
# Use the provided config file path or default to $NOVA_CONF.
local conf=${1:-$NOVA_CONF}
+ local offset=${2:-0}
+ # Stagger the offset based on the total number of possible console proxies
+ # (novnc, xvpvnc, spice, serial) so that their ports will not collide if
+ # all are enabled.
+ offset=$((offset * 4))
if is_service_enabled n-novnc || is_service_enabled n-xvnc || [ "$NOVA_VNC_ENABLED" != False ]; then
iniset $conf vnc novncproxy_host "$NOVA_SERVICE_LISTEN_ADDRESS"
+ iniset $conf vnc novncproxy_port $((6080 + offset))
iniset $conf vnc xvpvncproxy_host "$NOVA_SERVICE_LISTEN_ADDRESS"
+ iniset $conf vnc xvpvncproxy_port $((6081 + offset))
if is_nova_console_proxy_compute_tls_enabled ; then
iniset $conf vnc auth_schemes "vencrypt"
@@ -713,10 +722,12 @@
if is_service_enabled n-spice; then
iniset $conf spice html5proxy_host "$NOVA_SERVICE_LISTEN_ADDRESS"
+ iniset $conf spice html5proxy_port $((6082 + offset))
fi
if is_service_enabled n-sproxy; then
iniset $conf serial_console serialproxy_host "$NOVA_SERVICE_LISTEN_ADDRESS"
+ iniset $conf serial_console serialproxy_port $((6083 + offset))
fi
}