Deploy manila with uwsgi on devstack

Switch manila to use devstack common functions
for deploying a wsgi app under uwsgi and apache.

This change aims to fulfill the community requirement
for all projects on OpenStack to switch devstack jobs
to deploy control-plane API services under uwsgi with
Apache acting as a front end proxy.

More details in https://governance.openstack.org/tc/goals/pike/deploy-api-in-wsgi.html

We used to deploy with mod_wsgi, but mod_wsgi has many
issues when being used in devstack for development or testing.

Now we leave mod_wsgi as optional and we default to uwsgi.

Implements: bp wsgi-web-servers-support
Depends-On: https://review.openstack.org/#/c/643188/
Change-Id: I12d4c864f2ceb0f3555e32d2dc893e00dbef0d96
This commit is contained in:
Victoria Martinez de la Cruz 2019-02-04 23:20:00 +00:00 committed by Goutham Pacha Ravi
parent 4b0c953f7f
commit bd4673100b
3 changed files with 58 additions and 16 deletions

View File

@ -93,6 +93,7 @@ elif [[ "$DRIVER" == "dummy" ]]; then
# Run dummy driver CI job using standalone approach for running
# manila API service just because we need to test this approach too,
# that is very useful for development needs.
echo "MANILA_USE_UWSGI=False" >> $localconf
echo "MANILA_USE_MOD_WSGI=False" >> $localconf
echo "SHARE_DRIVER=$driver_path" >> $localconf

View File

@ -59,6 +59,10 @@ function cleanup_manila {
_clean_share_group $SHARE_GROUP $SHARE_NAME_PREFIX
_clean_manila_lvm_backing_file $SHARE_GROUP
_clean_zfsonlinux_data
if [ $(trueorfalse False MANILA_USE_UWSGI) == True ]; then
remove_uwsgi_config "$MANILA_UWSGI_CONF" "$MANILA_WSGI"
fi
}
# _config_manila_apache_wsgi() - Configure manila-api wsgi application.
@ -279,8 +283,9 @@ function configure_manila {
REAL_MANILA_SERVICE_PORT=$MANILA_SERVICE_PORT
if is_service_enabled tls-proxy; then
# Set the protocol to 'https', and set the default port
# Set the protocol to 'https', update the endpoint base and set the default port
MANILA_SERVICE_PROTOCOL="https"
MANILA_ENDPOINT_BASE="${MANILA_ENDPOINT_BASE/http:/https:}"
REAL_MANILA_SERVICE_PORT=$MANILA_SERVICE_PORT_INT
# Set the service port for a proxy to take the original
iniset $MANILA_CONF DEFAULT osapi_share_listen_port $REAL_MANILA_SERVICE_PORT
@ -296,6 +301,10 @@ function configure_manila {
set_config_opts DEFAULT
set_backend_availability_zones $MANILA_ENABLED_BACKENDS
if [ $(trueorfalse False MANILA_USE_UWSGI) == True ]; then
write_uwsgi_config "$MANILA_UWSGI_CONF" "$MANILA_WSGI" "/share"
fi
if [ $(trueorfalse False MANILA_USE_MOD_WSGI) == True ]; then
_config_manila_apache_wsgi
fi
@ -483,19 +492,14 @@ function create_manila_accounts {
create_service_user "manila"
# Set up Manila v1 service and endpoint
get_or_create_service "manila" "share" "Manila Shared Filesystem Service"
get_or_create_endpoint "share" "$REGION_NAME" \
"$MANILA_SERVICE_PROTOCOL://$MANILA_SERVICE_HOST:$MANILA_SERVICE_PORT/v1/\$(tenant_id)s" \
"$MANILA_SERVICE_PROTOCOL://$MANILA_SERVICE_HOST:$MANILA_SERVICE_PORT/v1/\$(tenant_id)s" \
"$MANILA_SERVICE_PROTOCOL://$MANILA_SERVICE_HOST:$MANILA_SERVICE_PORT/v1/\$(tenant_id)s"
"$MANILA_ENDPOINT_BASE/v1/\$(project_id)s"
# Set up Manila v2 service and endpoint
get_or_create_service "manilav2" "sharev2" "Manila Shared Filesystem Service V2"
get_or_create_endpoint "sharev2" "$REGION_NAME" \
"$MANILA_SERVICE_PROTOCOL://$MANILA_SERVICE_HOST:$MANILA_SERVICE_PORT/v2/\$(tenant_id)s" \
"$MANILA_SERVICE_PROTOCOL://$MANILA_SERVICE_HOST:$MANILA_SERVICE_PORT/v2/\$(tenant_id)s" \
"$MANILA_SERVICE_PROTOCOL://$MANILA_SERVICE_HOST:$MANILA_SERVICE_PORT/v2/\$(tenant_id)s"
"$MANILA_ENDPOINT_BASE/v2/\$(project_id)s"
}
# create_default_share_group_type - create share group type that will be set as default.
@ -817,28 +821,56 @@ function configure_samba {
# start_manila_api - starts manila API services and checks its availability
function start_manila_api {
if [ $(trueorfalse False MANILA_USE_MOD_WSGI) == True ]; then
# NOTE(vkmc) If both options are set to true we are using uwsgi
# as the preferred way to deploy manila. See
# https://governance.openstack.org/tc/goals/pike/deploy-api-in-wsgi.html#uwsgi-vs-mod-wsgi
# for more details
if [ $(trueorfalse False MANILA_USE_UWSGI) == True ] && [ $(trueorfalse False MANILA_USE_MOD_WSGI) == True ]; then
MSG="Both MANILA_USE_UWSGI and MANILA_USE_MOD_WSGI are set to True.
Using UWSGI as the preferred option
Set MANILA_USE_UWSGI to False to deploy manila api with MOD_WSGI"
warn $LINENO $MSG
fi
if [ $(trueorfalse False MANILA_USE_UWSGI) == True ]; then
echo "Deploying with UWSGI"
run_process m-api "$MANILA_BIN_DIR/uwsgi --ini $MANILA_UWSGI_CONF --procname-prefix manila-api"
elif [ $(trueorfalse False MANILA_USE_MOD_WSGI) == True ]; then
echo "Deploying with MOD_WSGI"
install_apache_wsgi
enable_apache_site manila-api
restart_apache_server
tail_log m-api /var/log/$APACHE_NAME/manila_api.log
else
echo "Deploying with built-in server"
run_process m-api "$MANILA_BIN_DIR/manila-api --config-file $MANILA_CONF"
fi
echo "Waiting for Manila API to start..."
# This is a health check against the manila-api service we just started.
# We use the port ($REAL_MANILA_SERVICE_PORT) here because we want to hit
# the bare service endpoint, even if the tls tunnel should be enabled.
# We're making sure that the internal port is checked using unencryted
# traffic at this point.
if ! wait_for_service $SERVICE_TIMEOUT $MANILA_SERVICE_PROTOCOL://$MANILA_SERVICE_HOST:$REAL_MANILA_SERVICE_PORT; then
local MANILA_HEALTH_CHECK_URL=$MANILA_SERVICE_PROTOCOL://$MANILA_SERVICE_HOST:$REAL_MANILA_SERVICE_PORT
if [ $(trueorfalse False MANILA_USE_UWSGI) == True ]; then
MANILA_HEALTH_CHECK_URL=$MANILA_ENDPOINT_BASE
fi
if ! wait_for_service $SERVICE_TIMEOUT $MANILA_HEALTH_CHECK_URL; then
die $LINENO "Manila API did not start"
fi
# Start proxies if enabled
if is_service_enabled tls-proxy; then
#
# If tls-proxy is enabled and MANILA_USE_UWSGI is set to True, a generic
# http-services-tls-proxy will be set up to handle tls-termination to
# manila as well as all the other https services, we don't need to
# create our own.
if [ $(trueorfalse False MANILA_USE_UWSGI) == False ] && is_service_enabled tls-proxy; then
start_tls_proxy manila '*' $MANILA_SERVICE_PORT $MANILA_SERVICE_HOST $MANILA_SERVICE_PORT_INT
fi
}

View File

@ -79,6 +79,7 @@ MANILA_SERVICE_HOST=${MANILA_SERVICE_HOST:-$SERVICE_HOST}
MANILA_SERVICE_PORT=${MANILA_SERVICE_PORT:-8786}
MANILA_SERVICE_PORT_INT=${MANILA_SERVICE_PORT_INT:-18786}
MANILA_SERVICE_PROTOCOL=${MANILA_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
MANILA_ENDPOINT_BASE=$MANILA_SERVICE_PROTOCOL://$MANILA_SERVICE_HOST:$MANILA_SERVICE_PORT
# Support entry points installation of console scripts
if [[ -d $MANILA_DIR/bin ]]; then
@ -99,13 +100,21 @@ MANILA_SERVICE_SECGROUP="manila-service"
# migrations again.
MANILA_USE_DOWNGRADE_MIGRATIONS=${MANILA_USE_DOWNGRADE_MIGRATIONS:-"False"}
# Toggle for deploying manila-api service under Apache web server with enabled 'mod_wsgi' plugin.
# Disabled by default, which means running manila-api service as standalone
# eventlet-based WSGI application.
# Toggle for deploying manila-api service under Apache web server with enabled
# 'mod_wsgi' plugin.
MANILA_USE_MOD_WSGI=${MANILA_USE_MOD_WSGI:-False}
# Toggle for deploying manila-api service with uWSGI
# Set it as True, because starting with Pike it is requirement from
# 'governance' project. See:
# https://governance.openstack.org/tc/goals/pike/deploy-api-in-wsgi.html#completion-criteria
MANILA_USE_MOD_WSGI=${MANILA_USE_MOD_WSGI:-True}
MANILA_USE_UWSGI=${MANILA_USE_UWSGI:-True}
MANILA_WSGI=$MANILA_BIN_DIR/manila-wsgi
MANILA_UWSGI_CONF=$MANILA_CONF_DIR/manila-uwsgi.ini
if [ $(trueorfalse False MANILA_USE_UWSGI) == True ]; then
MANILA_ENDPOINT_BASE=$MANILA_SERVICE_PROTOCOL://$MANILA_SERVICE_HOST/share
fi
# Common info for Generic driver(s)
SHARE_DRIVER=${SHARE_DRIVER:-manila.share.drivers.generic.GenericShareDriver}