Revert "Remove deprecated PostgreSQL database driver"
This reverts commit 168ca7f0a4
.
Removing postgresql support from devstack was unnecessary
since it's not broken and not causing maintenance issues
as far as I know. The commit being reverted said that pg
support was deprecated in Pike but nothing in the docs or
commit message refer to official deprecation of postgres
support in devstack or openstack in general. Not to mention
that there are still postgres-based jobs that will no
longer work *and* the notification to the mailing list about
doing this happened *after* it was already done [1] leaving
stakeholders with no time to reply.
[1] http://lists.openstack.org/pipermail/openstack-discuss/2019-October/010196.html
Change-Id: Ie7036d37d79e6aba462b7c97f917e2e7aed108f9
This commit is contained in:
parent
cf1c847191
commit
b14665f0dd
@ -326,23 +326,29 @@ a file, keep service logs and disable color in the stored files.
|
|||||||
Database Backend
|
Database Backend
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
Support for the MySQL database backend is included. Addition database backends
|
Multiple database backends are available. The available databases are defined
|
||||||
may be available via external plugins. Enabling of disabling MySQL is handled
|
in the lib/databases directory.
|
||||||
via the usual service functions and ``ENABLED_SERVICES``. For example, to
|
``mysql`` is the default database, choose a different one by putting the
|
||||||
disable MySQL in ``local.conf``::
|
following in the ``localrc`` section::
|
||||||
|
|
||||||
disable_service mysql
|
disable_service mysql
|
||||||
|
enable_service postgresql
|
||||||
|
|
||||||
|
``mysql`` is the default database.
|
||||||
|
|
||||||
RPC Backend
|
RPC Backend
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
Support for a RabbitMQ RPC backend is included. Additional RPC backends may be
|
Support for a RabbitMQ RPC backend is included. Additional RPC
|
||||||
available via external plugins. Enabling or disabling RabbitMQ is handled via
|
backends may be available via external plugins. Enabling or disabling
|
||||||
the usual service functions and ``ENABLED_SERVICES``. For example, to disable
|
RabbitMQ is handled via the usual service functions and
|
||||||
RabbitMQ in ``local.conf``::
|
``ENABLED_SERVICES``.
|
||||||
|
|
||||||
|
Example disabling RabbitMQ in ``local.conf``::
|
||||||
|
|
||||||
disable_service rabbit
|
disable_service rabbit
|
||||||
|
|
||||||
|
|
||||||
Apache Frontend
|
Apache Frontend
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
@ -302,7 +302,10 @@ migrated at all.
|
|||||||
- This will probably be implemented on ironic side.
|
- This will probably be implemented on ironic side.
|
||||||
* - DEVSTACK_GATE_POSTGRES
|
* - DEVSTACK_GATE_POSTGRES
|
||||||
- Legacy
|
- Legacy
|
||||||
- This has no effect in d-g.
|
- This flag exists in d-g but the only thing that it does is
|
||||||
|
capture postgres logs. This is already supported by the roles
|
||||||
|
in post, so the flag is useless in the new jobs. postgres
|
||||||
|
itself can be enabled via the devstack_service job variable.
|
||||||
* - DEVSTACK_GATE_ZEROMQ
|
* - DEVSTACK_GATE_ZEROMQ
|
||||||
- Legacy
|
- Legacy
|
||||||
- This has no effect in d-g.
|
- This has no effect in d-g.
|
||||||
|
@ -400,8 +400,7 @@ function upload_image {
|
|||||||
# initialized yet, just save the configuration selection and call back later
|
# initialized yet, just save the configuration selection and call back later
|
||||||
# to validate it.
|
# to validate it.
|
||||||
#
|
#
|
||||||
# ``$1`` - the name of the database backend to use (only mysql is currently
|
# ``$1`` - the name of the database backend to use (mysql, postgresql, ...)
|
||||||
# supported)
|
|
||||||
function use_database {
|
function use_database {
|
||||||
if [[ -z "$DATABASE_BACKENDS" ]]; then
|
if [[ -z "$DATABASE_BACKENDS" ]]; then
|
||||||
# No backends registered means this is likely called from ``localrc``
|
# No backends registered means this is likely called from ``localrc``
|
||||||
|
137
lib/databases/postgresql
Normal file
137
lib/databases/postgresql
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# lib/databases/postgresql
|
||||||
|
# Functions to control the configuration and operation of the **PostgreSQL** database backend
|
||||||
|
|
||||||
|
# Dependencies:
|
||||||
|
#
|
||||||
|
# - DATABASE_{HOST,USER,PASSWORD} must be defined
|
||||||
|
|
||||||
|
# Save trace setting
|
||||||
|
_XTRACE_PG=$(set +o | grep xtrace)
|
||||||
|
set +o xtrace
|
||||||
|
|
||||||
|
|
||||||
|
MAX_DB_CONNECTIONS=${MAX_DB_CONNECTIONS:-200}
|
||||||
|
|
||||||
|
|
||||||
|
register_database postgresql
|
||||||
|
|
||||||
|
|
||||||
|
# Functions
|
||||||
|
# ---------
|
||||||
|
|
||||||
|
function get_database_type_postgresql {
|
||||||
|
echo postgresql
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get rid of everything enough to cleanly change database backends
|
||||||
|
function cleanup_database_postgresql {
|
||||||
|
stop_service postgresql
|
||||||
|
if is_ubuntu; then
|
||||||
|
# Get ruthless with mysql
|
||||||
|
apt_get purge -y postgresql*
|
||||||
|
return
|
||||||
|
elif is_fedora || is_suse; then
|
||||||
|
uninstall_package postgresql-server
|
||||||
|
else
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function recreate_database_postgresql {
|
||||||
|
local db=$1
|
||||||
|
# Avoid unsightly error when calling dropdb when the database doesn't exist
|
||||||
|
psql -h$DATABASE_HOST -U$DATABASE_USER -dtemplate1 -c "DROP DATABASE IF EXISTS $db"
|
||||||
|
createdb -h $DATABASE_HOST -U$DATABASE_USER -l C -T template0 -E utf8 $db
|
||||||
|
}
|
||||||
|
|
||||||
|
function configure_database_postgresql {
|
||||||
|
local pg_conf pg_dir pg_hba check_role version
|
||||||
|
echo_summary "Configuring and starting PostgreSQL"
|
||||||
|
if is_fedora; then
|
||||||
|
pg_hba=/var/lib/pgsql/data/pg_hba.conf
|
||||||
|
pg_conf=/var/lib/pgsql/data/postgresql.conf
|
||||||
|
if ! sudo [ -e $pg_hba ]; then
|
||||||
|
sudo postgresql-setup initdb
|
||||||
|
fi
|
||||||
|
elif is_ubuntu; then
|
||||||
|
version=`psql --version | cut -d ' ' -f3 | cut -d. -f1-2`
|
||||||
|
if vercmp $version '>=' 9.3; then
|
||||||
|
if [ -z "`pg_lsclusters -h`" ]; then
|
||||||
|
echo 'No PostgreSQL clusters exist; will create one'
|
||||||
|
sudo pg_createcluster $version main --start
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
pg_dir=`find /etc/postgresql -name pg_hba.conf|xargs dirname`
|
||||||
|
pg_hba=$pg_dir/pg_hba.conf
|
||||||
|
pg_conf=$pg_dir/postgresql.conf
|
||||||
|
elif is_suse; then
|
||||||
|
pg_hba=/var/lib/pgsql/data/pg_hba.conf
|
||||||
|
pg_conf=/var/lib/pgsql/data/postgresql.conf
|
||||||
|
# initdb is called when postgresql is first started
|
||||||
|
sudo [ -e $pg_hba ] || start_service postgresql
|
||||||
|
else
|
||||||
|
exit_distro_not_supported "postgresql configuration"
|
||||||
|
fi
|
||||||
|
# Listen on all addresses
|
||||||
|
sudo sed -i "/listen_addresses/s/.*/listen_addresses = '*'/" $pg_conf
|
||||||
|
# Set max_connections
|
||||||
|
sudo sed -i "/max_connections/s/.*/max_connections = $MAX_DB_CONNECTIONS/" $pg_conf
|
||||||
|
# Do password auth from all IPv4 clients
|
||||||
|
sudo sed -i "/^host/s/all\s\+127.0.0.1\/32\s\+ident/$DATABASE_USER\t0.0.0.0\/0\tpassword/" $pg_hba
|
||||||
|
# Do password auth for all IPv6 clients
|
||||||
|
sudo sed -i "/^host/s/all\s\+::1\/128\s\+ident/$DATABASE_USER\t::0\/0\tpassword/" $pg_hba
|
||||||
|
restart_service postgresql
|
||||||
|
|
||||||
|
# Create the role if it's not here or else alter it.
|
||||||
|
check_role=$(sudo -u root sudo -u postgres -i psql -t -c "SELECT 'HERE' from pg_roles where rolname='$DATABASE_USER'")
|
||||||
|
if [[ ${check_role} == *HERE ]];then
|
||||||
|
sudo -u root sudo -u postgres -i psql -c "ALTER ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
|
||||||
|
else
|
||||||
|
sudo -u root sudo -u postgres -i psql -c "CREATE ROLE $DATABASE_USER WITH SUPERUSER LOGIN PASSWORD '$DATABASE_PASSWORD'"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_database_postgresql {
|
||||||
|
echo_summary "Installing postgresql"
|
||||||
|
deprecated "Use of postgresql in devstack is deprecated, and will be removed during the Pike cycle"
|
||||||
|
local pgpass=$HOME/.pgpass
|
||||||
|
if [[ ! -e $pgpass ]]; then
|
||||||
|
cat <<EOF > $pgpass
|
||||||
|
*:*:*:$DATABASE_USER:$DATABASE_PASSWORD
|
||||||
|
EOF
|
||||||
|
chmod 0600 $pgpass
|
||||||
|
else
|
||||||
|
sed -i "s/:root:\w\+/:root:$DATABASE_PASSWORD/" $pgpass
|
||||||
|
fi
|
||||||
|
if is_ubuntu; then
|
||||||
|
install_package postgresql
|
||||||
|
elif is_fedora || is_suse; then
|
||||||
|
install_package postgresql-server
|
||||||
|
if is_fedora; then
|
||||||
|
sudo systemctl enable postgresql
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
exit_distro_not_supported "postgresql installation"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_database_python_postgresql {
|
||||||
|
# Install Python client module
|
||||||
|
pip_install_gr psycopg2
|
||||||
|
ADDITIONAL_VENV_PACKAGES+=",psycopg2"
|
||||||
|
}
|
||||||
|
|
||||||
|
function database_connection_url_postgresql {
|
||||||
|
local db=$1
|
||||||
|
echo "$BASE_SQL_CONN/$db?client_encoding=utf8"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Restore xtrace
|
||||||
|
$_XTRACE_PG
|
||||||
|
|
||||||
|
# Local variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# End:
|
9
stack.sh
9
stack.sh
@ -695,11 +695,14 @@ function read_password {
|
|||||||
# Database Configuration
|
# Database Configuration
|
||||||
# ----------------------
|
# ----------------------
|
||||||
|
|
||||||
# DevStack provides a MySQL database backend. Additional backends may be
|
# To select between database backends, add the following to ``local.conf``:
|
||||||
# provided by external plugins and can be enabled using the usual service
|
|
||||||
# functions and ``ENABLED_SERVICES``. For example, to disable MySQL:
|
|
||||||
#
|
#
|
||||||
# disable_service mysql
|
# disable_service mysql
|
||||||
|
# enable_service postgresql
|
||||||
|
#
|
||||||
|
# The available database backends are listed in ``DATABASE_BACKENDS`` after
|
||||||
|
# ``lib/database`` is sourced. ``mysql`` is the default.
|
||||||
|
|
||||||
if initialize_database_backends; then
|
if initialize_database_backends; then
|
||||||
echo "Using $DATABASE_TYPE database backend"
|
echo "Using $DATABASE_TYPE database backend"
|
||||||
# Last chance for the database password. This must be handled here
|
# Last chance for the database password. This must be handled here
|
||||||
|
@ -147,6 +147,10 @@ if [[ -n "$UNSTACK_ALL" ]]; then
|
|||||||
stop_service mysql
|
stop_service mysql
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if is_service_enabled postgresql; then
|
||||||
|
stop_service postgresql
|
||||||
|
fi
|
||||||
|
|
||||||
# Stop rabbitmq-server
|
# Stop rabbitmq-server
|
||||||
if is_service_enabled rabbit; then
|
if is_service_enabled rabbit; then
|
||||||
stop_service rabbitmq-server
|
stop_service rabbitmq-server
|
||||||
|
Loading…
Reference in New Issue
Block a user