Skip to content

Commit f63aa02

Browse files
committed
Fleetify nova conductor for N cells
This makes us start two levels of nova-conductor processes, and one per cell. Change-Id: Ice4aceac5dc44954db3661480b9365f54e47a4c9
1 parent 9234316 commit f63aa02

2 files changed

Lines changed: 102 additions & 13 deletions

File tree

lib/nova

Lines changed: 99 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,18 @@ NOVA_AUTH_CACHE_DIR=${NOVA_AUTH_CACHE_DIR:-/var/cache/nova}
5353
NOVA_CONF_DIR=/etc/nova
5454
NOVA_CONF=$NOVA_CONF_DIR/nova.conf
5555
NOVA_CELLS_CONF=$NOVA_CONF_DIR/nova-cells.conf
56+
NOVA_CPU_CONF=$NOVA_CONF_DIR/nova-cpu.conf
5657
NOVA_FAKE_CONF=$NOVA_CONF_DIR/nova-fake.conf
5758
NOVA_CELLS_DB=${NOVA_CELLS_DB:-nova_cell}
5859
NOVA_API_DB=${NOVA_API_DB:-nova_api}
5960

61+
# The total number of cells we expect. Must be greater than one and doesn't
62+
# count cell0.
63+
NOVA_NUM_CELLS=${NOVA_NUM_CELLS:-1}
64+
# Our cell index, so we know what rabbit vhost to connect to.
65+
# This should be in the range of 1-$NOVA_NUM_CELLS
66+
NOVA_CPU_CELL=${NOVA_CPU_CELL:-1}
67+
6068
NOVA_API_PASTE_INI=${NOVA_API_PASTE_INI:-$NOVA_CONF_DIR/api-paste.ini}
6169

6270
if is_suse; then
@@ -479,7 +487,7 @@ function create_nova_conf {
479487
# require them running on the host. The ensures that n-cpu doesn't
480488
# leak a need to use the db in a multinode scenario.
481489
if is_service_enabled n-api n-cond n-sched; then
482-
iniset $NOVA_CONF database connection `database_connection_url nova`
490+
iniset $NOVA_CONF database connection `database_connection_url nova_cell0`
483491
iniset $NOVA_CONF api_database connection `database_connection_url nova_api`
484492
fi
485493

@@ -614,6 +622,20 @@ function create_nova_conf {
614622
if [ "$NOVA_USE_SERVICE_TOKEN" == "True" ]; then
615623
init_nova_service_user_conf
616624
fi
625+
626+
if is_service_enabled n-cond; then
627+
for i in $(seq 1 $NOVA_NUM_CELLS); do
628+
local conf
629+
local vhost
630+
conf=$(conductor_conf $i)
631+
vhost="nova_cell${i}"
632+
iniset $conf database connection `database_connection_url nova_cell${i}`
633+
iniset $conf conductor workers "$API_WORKERS"
634+
iniset $conf DEFAULT debug "$ENABLE_DEBUG_LOG_LEVEL"
635+
rpc_backend_add_vhost $vhost
636+
iniset_rpc_backend nova $conf DEFAULT $vhost
637+
done
638+
fi
617639
}
618640

619641
function init_nova_service_user_conf {
@@ -628,6 +650,11 @@ function init_nova_service_user_conf {
628650
iniset $NOVA_CONF service_user auth_strategy keystone
629651
}
630652

653+
function conductor_conf {
654+
local cell="$1"
655+
echo "${NOVA_CONF_DIR}/nova_cell${cell}.conf"
656+
}
657+
631658
function init_nova_cells {
632659
if is_service_enabled n-cell; then
633660
cp $NOVA_CONF $NOVA_CELLS_CONF
@@ -692,8 +719,6 @@ function init_nova {
692719
recreate_database $NOVA_API_DB
693720
$NOVA_BIN_DIR/nova-manage --config-file $NOVA_CONF api_db sync
694721

695-
# (Re)create nova databases
696-
recreate_database nova
697722
recreate_database nova_cell0
698723

699724
# map_cell0 will create the cell mapping record in the nova_api DB so
@@ -705,6 +730,12 @@ function init_nova {
705730
# Migrate nova and nova_cell0 databases.
706731
$NOVA_BIN_DIR/nova-manage --config-file $NOVA_CONF db sync
707732

733+
# (Re)create nova databases
734+
for i in $(seq 1 $NOVA_NUM_CELLS); do
735+
recreate_database nova_cell${i}
736+
$NOVA_BIN_DIR/nova-manage --config-file $(conductor_conf $i) db sync
737+
done
738+
708739
if is_service_enabled n-cell; then
709740
recreate_database $NOVA_CELLS_DB
710741
fi
@@ -713,9 +744,13 @@ function init_nova {
713744
# Needed for flavor conversion
714745
$NOVA_BIN_DIR/nova-manage --config-file $NOVA_CONF db online_data_migrations
715746

747+
# FIXME(danms): Should this be configurable?
748+
iniset $NOVA_CONF workarounds disable_group_policy_check_upcall True
749+
716750
# create the cell1 cell for the main nova db where the hosts live
717-
nova-manage cell_v2 create_cell --transport-url $(get_transport_url) \
718-
--name 'cell1'
751+
for i in $(seq 1 $NOVA_NUM_CELLS); do
752+
nova-manage --config-file $NOVA_CONF --config-file $(conductor_conf $i) cell_v2 create_cell --name "cell$i"
753+
done
719754
fi
720755

721756
create_nova_cache_dir
@@ -823,25 +858,38 @@ function start_nova_api {
823858

824859
# start_nova_compute() - Start the compute process
825860
function start_nova_compute {
861+
local nomulticellflag="$1"
826862
# Hack to set the path for rootwrap
827863
local old_path=$PATH
828864
export PATH=$NOVA_BIN_DIR:$PATH
829865

830866
if is_service_enabled n-cell; then
831867
local compute_cell_conf=$NOVA_CELLS_CONF
868+
# NOTE(danms): Don't setup conductor fleet for cellsv1
869+
nomulticellflag='nomulticell'
832870
else
833871
local compute_cell_conf=$NOVA_CONF
834872
fi
835873

874+
if [ "$nomulticellflag" = 'nomulticell' ]; then
875+
# NOTE(danms): Grenade doesn't setup multi-cell rabbit, so
876+
# skip these bits and use the normal config.
877+
NOVA_CPU_CONF=$compute_cell_conf
878+
echo "Skipping multi-cell conductor fleet setup"
879+
else
880+
cp $compute_cell_conf $NOVA_CPU_CONF
881+
iniset_rpc_backend nova $NOVA_CPU_CONF DEFAULT "nova_cell${NOVA_CPU_CELL}"
882+
fi
883+
836884
if [[ "$VIRT_DRIVER" = 'libvirt' ]]; then
837885
# The group **$LIBVIRT_GROUP** is added to the current user in this script.
838886
# ``sg`` is used in run_process to execute nova-compute as a member of the
839887
# **$LIBVIRT_GROUP** group.
840-
run_process n-cpu "$NOVA_BIN_DIR/nova-compute --config-file $compute_cell_conf" $LIBVIRT_GROUP
888+
run_process n-cpu "$NOVA_BIN_DIR/nova-compute --config-file $NOVA_CPU_CONF" $LIBVIRT_GROUP
841889
elif [[ "$VIRT_DRIVER" = 'lxd' ]]; then
842-
run_process n-cpu "$NOVA_BIN_DIR/nova-compute --config-file $compute_cell_conf" $LXD_GROUP
890+
run_process n-cpu "$NOVA_BIN_DIR/nova-compute --config-file $NOVA_CPU_CONF" $LXD_GROUP
843891
elif [[ "$VIRT_DRIVER" = 'docker' || "$VIRT_DRIVER" = 'zun' ]]; then
844-
run_process n-cpu "$NOVA_BIN_DIR/nova-compute --config-file $compute_cell_conf" $DOCKER_GROUP
892+
run_process n-cpu "$NOVA_BIN_DIR/nova-compute --config-file $NOVA_CPU_CONF" $DOCKER_GROUP
845893
elif [[ "$VIRT_DRIVER" = 'fake' ]]; then
846894
local i
847895
for i in `seq 1 $NUMBER_FAKE_NOVA_COMPUTE`; do
@@ -850,13 +898,13 @@ function start_nova_compute {
850898
# gets its own configuration and own log file.
851899
local fake_conf="${NOVA_FAKE_CONF}-${i}"
852900
iniset $fake_conf DEFAULT nhost "${HOSTNAME}${i}"
853-
run_process "n-cpu-${i}" "$NOVA_BIN_DIR/nova-compute --config-file $compute_cell_conf --config-file $fake_conf"
901+
run_process "n-cpu-${i}" "$NOVA_BIN_DIR/nova-compute --config-file $NOVA_CPU_CONF --config-file $fake_conf"
854902
done
855903
else
856904
if is_service_enabled n-cpu && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then
857905
start_nova_hypervisor
858906
fi
859-
run_process n-cpu "$NOVA_BIN_DIR/nova-compute --config-file $compute_cell_conf"
907+
run_process n-cpu "$NOVA_BIN_DIR/nova-compute --config-file $NOVA_CPU_CONF"
860908
fi
861909

862910
export PATH=$old_path
@@ -876,7 +924,6 @@ function start_nova_rest {
876924
fi
877925

878926
# ``run_process`` checks ``is_service_enabled``, it is not needed here
879-
run_process n-cond "$NOVA_BIN_DIR/nova-conductor --config-file $compute_cell_conf"
880927
run_process n-cell-region "$NOVA_BIN_DIR/nova-cells --config-file $api_cell_conf"
881928
run_process n-cell-child "$NOVA_BIN_DIR/nova-cells --config-file $compute_cell_conf"
882929

@@ -899,8 +946,38 @@ function start_nova_rest {
899946
export PATH=$old_path
900947
}
901948

949+
function enable_nova_fleet {
950+
if is_service_enabled n-cond; then
951+
enable_service n-super-cond
952+
for i in $(seq 1 $NOVA_NUM_CELLS); do
953+
enable_service n-cond-cell${i}
954+
done
955+
fi
956+
}
957+
958+
function start_nova_conductor {
959+
if is_service_enabled n-cell; then
960+
echo "Starting nova-conductor in a cellsv1-compatible way"
961+
run_process n-cond "$NOVA_BIN_DIR/nova-conductor --config-file $NOVA_CELLS_CONF"
962+
return
963+
fi
964+
965+
enable_nova_fleet
966+
if is_service_enabled n-super-cond; then
967+
run_process n-super-cond "$NOVA_BIN_DIR/nova-conductor --config-file $NOVA_CONF"
968+
fi
969+
for i in $(seq 1 $NOVA_NUM_CELLS); do
970+
if is_service_enabled n-cond-cell${i}; then
971+
local conf
972+
conf=$(conductor_conf $i)
973+
run_process n-cond-cell${i} "$NOVA_BIN_DIR/nova-conductor --config-file $conf"
974+
fi
975+
done
976+
}
977+
902978
function start_nova {
903979
start_nova_rest
980+
start_nova_conductor
904981
start_nova_compute
905982
}
906983

@@ -929,14 +1006,24 @@ function stop_nova_rest {
9291006
# Kill the nova screen windows
9301007
# Some services are listed here twice since more than one instance
9311008
# of a service may be running in certain configs.
932-
for serv in n-api n-net n-sch n-novnc n-xvnc n-cauth n-spice n-cond n-cell n-cell n-api-meta n-sproxy; do
1009+
for serv in n-api n-net n-sch n-novnc n-xvnc n-cauth n-spice n-cell n-cell n-api-meta n-sproxy; do
9331010
stop_process $serv
9341011
done
9351012
}
9361013

1014+
function stop_nova_conductor {
1015+
enable_nova_fleet
1016+
for srv in n-super-cond $(seq -f n-cond-cell%0.f 1 $NOVA_NUM_CELLS); do
1017+
if is_service_enabled $srv; then
1018+
stop_process $srv
1019+
fi
1020+
done
1021+
}
1022+
9371023
# stop_nova() - Stop running processes (non-screen)
9381024
function stop_nova {
9391025
stop_nova_rest
1026+
stop_nova_conductor
9401027
stop_nova_compute
9411028
}
9421029

stack.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,9 @@ fi
12681268
# Unable to use LUKS passphrase that is exactly 16 bytes long
12691269
# https://bugzilla.redhat.com/show_bug.cgi?id=1447297
12701270
if is_service_enabled nova; then
1271-
iniset $NOVA_CONF key_manager fixed_key $(generate_hex_string 36)
1271+
key=$(generate_hex_string 36)
1272+
iniset $NOVA_CONF key_manager fixed_key "$key"
1273+
iniset $NOVA_CPU_CONF key_manager fixed_key "$key"
12721274
fi
12731275

12741276
# Launch the nova-api and wait for it to answer before continuing

0 commit comments

Comments
 (0)