Create config file before database migrate

In the from-rocky placement extraction script, this patch reverses
the order to migrate the database and to create the placement.conf.

This is because ``[placement_database]/connection`` should be set
before the database migration shell script is executed if we want
to stamp the database version within the shell script.

Needed-By: https://review.openstack.org/621733
Change-Id: I8fe401814f887c8b29f1c6262d8b9e5263a07bcc
This commit is contained in:
Tetsuro Nakamura 2018-11-27 13:19:52 +00:00 committed by Matt Riedemann
parent 2f03ec23fd
commit f78a588f68

View File

@ -41,24 +41,8 @@ function configure_nova_upgrade() {
# Get our database variables set.
initialize_database_backends
# Write out the migrate-db.rc file.
local rc_file=/tmp/migrate-db.rc
touch ${rc_file}
# $db_script is an absolute path so we can execute it directly.
${db_script} --mkconfig ${rc_file}
sed -i s/NOVA_API_USER.*/NOVA_API_USER=\"${DATABASE_USER}\"/g ${rc_file}
sed -i s/NOVA_API_PASS.*/NOVA_API_PASS=\"${DATABASE_PASSWORD}\"/g ${rc_file}
sed -i s/PLACEMENT_USER.*/PLACEMENT_USER=\"${DATABASE_USER}\"/g ${rc_file}
sed -i s/PLACEMENT_PASS.*/PLACEMENT_PASS=\"${DATABASE_PASSWORD}\"/g ${rc_file}
# Create the placement database.
recreate_database placement
# Copy the placement-related table data from the nova_api database
# into the placement database.
${db_script} --migrate ${rc_file}
# Write out the contents of placement.conf.
# This should be done before executing the database migration script.
local placement_conf_dir=/etc/placement
sudo install -d -o ${STACK_USER} ${placement_conf_dir}
local placement_conf=${placement_conf_dir}/placement.conf
@ -84,6 +68,25 @@ function configure_nova_upgrade() {
fi
done
# Write out the migrate-db.rc file.
local rc_file=/tmp/migrate-db.rc
touch ${rc_file}
# $db_script is an absolute path so we can execute it directly.
${db_script} --mkconfig ${rc_file}
sed -i s/NOVA_API_USER.*/NOVA_API_USER=\"${DATABASE_USER}\"/g ${rc_file}
sed -i s/NOVA_API_PASS.*/NOVA_API_PASS=\"${DATABASE_PASSWORD}\"/g ${rc_file}
sed -i s/PLACEMENT_USER.*/PLACEMENT_USER=\"${DATABASE_USER}\"/g ${rc_file}
sed -i s/PLACEMENT_PASS.*/PLACEMENT_PASS=\"${DATABASE_PASSWORD}\"/g ${rc_file}
# Create the placement database.
recreate_database placement
# Copy the placement-related table data from the nova_api database into
# the placement database and "stamp" the database version to bring it
# under alembic control. Note that stamping relies on the
# `placement.conf` having `[placement_database]/connection` set first.
${db_script} --migrate ${rc_file}
# Copy any policy overrides from nova. We assume yaml here since that is
# the default in code, but it could also be a json file.
local old_policy_file=${NOVA_CONF_DIR}/placement-policy.yaml