Skip to content

Commit d7d902f

Browse files
melwittstephenfin
authored andcommitted
Configure console proxy ports in nova-cpu.conf
In change I8934d0b9392f2976347391c8a650ad260f337762, we began configuring console proxy ports for multiple cells in the nova controller config files to avoid "Address already in use" errors from port collisions when running multiple cells on a single host. This correspondingly configures the console proxy ports in the nova compute config file based on what cell we're in, according to the NOVA_CPU_CELL variable. The base_url config for serial console is also added where the default was previously used. The url is taken from the config option default in the nova code: nova/conf/serial_console.py [1]. [1] https://github.com/openstack/nova/blob/8f00b5d/nova/conf/serial_console.py#L54 Change-Id: Id885fc5a769bce8111f1052a1b55d26be817c890 Closes-Bug: #1830417
1 parent 8b31dce commit d7d902f

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

lib/nova

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -572,23 +572,34 @@ function configure_placement_nova_compute {
572572
}
573573

574574
function configure_console_compute {
575+
# If we are running multiple cells (and thus multiple console proxies) on a
576+
# single host, we offset the ports to avoid collisions. We need to
577+
# correspondingly configure the console proxy port for nova-compute and we
578+
# can use the NOVA_CPU_CELL variable to know which cell we are for
579+
# calculating the offset.
580+
# Stagger the offset based on the total number of possible console proxies
581+
# (novnc, xvpvnc, spice, serial) so that their ports will not collide if
582+
# all are enabled.
583+
local offset
584+
offset=$(((NOVA_CPU_CELL - 1) * 4))
585+
575586
# All nova-compute workers need to know the vnc configuration options
576587
# These settings don't hurt anything if n-xvnc and n-novnc are disabled
577588
if is_service_enabled n-cpu; then
578589
if [ "$NOVNC_FROM_PACKAGE" == "True" ]; then
579590
# Use the old URL when installing novnc packages.
580-
NOVNCPROXY_URL=${NOVNCPROXY_URL:-"http://$SERVICE_HOST:6080/vnc_auto.html"}
591+
NOVNCPROXY_URL=${NOVNCPROXY_URL:-"http://$SERVICE_HOST:$((6080 + offset))/vnc_auto.html"}
581592
elif vercmp ${NOVNC_BRANCH} "<" "1.0.0"; then
582-
# Use the old URL when installing older novnc source.
583-
NOVNCPROXY_URL=${NOVNCPROXY_URL:-"http://$SERVICE_HOST:6080/vnc_auto.html"}
593+
# Use the old URL when installing older novnc source.
594+
NOVNCPROXY_URL=${NOVNCPROXY_URL:-"http://$SERVICE_HOST:$((6080 + offset))/vnc_auto.html"}
584595
else
585596
# Use the new URL when building >=v1.0.0 from source.
586-
NOVNCPROXY_URL=${NOVNCPROXY_URL:-"http://$SERVICE_HOST:6080/vnc_lite.html"}
597+
NOVNCPROXY_URL=${NOVNCPROXY_URL:-"http://$SERVICE_HOST:$((6080 + offset))/vnc_lite.html"}
587598
fi
588599
iniset $NOVA_CPU_CONF vnc novncproxy_base_url "$NOVNCPROXY_URL"
589-
XVPVNCPROXY_URL=${XVPVNCPROXY_URL:-"http://$SERVICE_HOST:6081/console"}
600+
XVPVNCPROXY_URL=${XVPVNCPROXY_URL:-"http://$SERVICE_HOST:$((6081 + offset))/console"}
590601
iniset $NOVA_CPU_CONF vnc xvpvncproxy_base_url "$XVPVNCPROXY_URL"
591-
SPICEHTML5PROXY_URL=${SPICEHTML5PROXY_URL:-"http://$SERVICE_HOST:6082/spice_auto.html"}
602+
SPICEHTML5PROXY_URL=${SPICEHTML5PROXY_URL:-"http://$SERVICE_HOST:$((6082 + offset))/spice_auto.html"}
592603
iniset $NOVA_CPU_CONF spice html5proxy_base_url "$SPICEHTML5PROXY_URL"
593604
fi
594605

@@ -615,6 +626,7 @@ function configure_console_compute {
615626

616627
if is_service_enabled n-sproxy; then
617628
iniset $NOVA_CPU_CONF serial_console enabled True
629+
iniset $NOVA_CPU_CONF serial_console base_url "ws://$SERVICE_HOST:$((6083 + offset))/"
618630
fi
619631
}
620632

0 commit comments

Comments
 (0)