Browse code

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

melanie witt authored on 2019/05/25 05:09:28
Showing 1 changed files
... ...
@@ -572,23 +572,34 @@ function configure_placement_nova_compute {
572 572
 }
573 573
 
574 574
 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
+
575 586
     # All nova-compute workers need to know the vnc configuration options
576 587
     # These settings don't hurt anything if n-xvnc and n-novnc are disabled
577 588
     if is_service_enabled n-cpu; then
578 589
         if [ "$NOVNC_FROM_PACKAGE" == "True" ]; then
579 590
             # 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"}
581 592
         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"}
584 595
         else
585 596
             # 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"}
587 598
         fi
588 599
         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"}
590 601
         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"}
592 603
         iniset $NOVA_CPU_CONF spice html5proxy_base_url "$SPICEHTML5PROXY_URL"
593 604
     fi
594 605
 
... ...
@@ -615,6 +626,7 @@ function configure_console_compute {
615 615
 
616 616
     if is_service_enabled n-sproxy; then
617 617
         iniset $NOVA_CPU_CONF serial_console enabled True
618
+        iniset $NOVA_CPU_CONF serial_console base_url "ws://$SERVICE_HOST:$((6083 + offset))/"
618 619
     fi
619 620
 }
620 621