Do not use hardcoded IPv4 localhost value
There are a couple of places that still use a hardcoded
127.0.0.1 value, even if devstack is run with
SERVICE_IP_VERSION=6 in local.conf. While things still
work, SERVICE_LOCAL_HOST should be used instead since
everything else could be using IPv6.
Change-Id: I2dd9247a4ac19f565d4d5ecb2e1490501fda8bca
diff --git a/lib/apache b/lib/apache
index f29c7ea..02827d1 100644
--- a/lib/apache
+++ b/lib/apache
@@ -27,6 +27,11 @@
APACHE_USER=${APACHE_USER:-$STACK_USER}
APACHE_GROUP=${APACHE_GROUP:-$(id -gn $APACHE_USER)}
+APACHE_LOCAL_HOST=$SERVICE_LOCAL_HOST
+if [[ "$SERVICE_IP_VERSION" == 6 ]]; then
+ APACHE_LOCAL_HOST=[$APACHE_LOCAL_HOST]
+fi
+
# Set up apache name and configuration directory
# Note that APACHE_CONF_DIR is really more accurately apache's vhost
@@ -323,7 +328,7 @@
rm -rf $file
iniset "$file" uwsgi wsgi-file "$wsgi"
port=$(get_random_port)
- iniset "$file" uwsgi http-socket "127.0.0.1:$port"
+ iniset "$file" uwsgi http-socket "$APACHE_LOCAL_HOST:$port"
iniset "$file" uwsgi processes $API_WORKERS
# This is running standalone
iniset "$file" uwsgi master true
@@ -359,7 +364,7 @@
apache_conf=$(apache_site_config_for $name)
echo "KeepAlive Off" | sudo tee $apache_conf
echo "SetEnv proxy-sendchunked 1" | sudo tee -a $apache_conf
- echo "ProxyPass \"${url}\" \"http://127.0.0.1:$port\" retry=0 " | sudo tee -a $apache_conf
+ echo "ProxyPass \"${url}\" \"http://$APACHE_LOCAL_HOST:$port\" retry=0 " | sudo tee -a $apache_conf
enable_apache_site $name
restart_apache_server
}
diff --git a/lib/databases/mysql b/lib/databases/mysql
index 30e4b7c..0f45273 100644
--- a/lib/databases/mysql
+++ b/lib/databases/mysql
@@ -86,10 +86,16 @@
exit_distro_not_supported "mysql configuration"
fi
- # Start mysql-server
+ # Change bind-address from localhost (127.0.0.1) to any (::)
+ iniset -sudo $my_conf mysqld bind-address "$(ipv6_unquote $SERVICE_LISTEN_ADDRESS)"
+
+ # (Re)Start mysql-server
if is_fedora || is_suse; then
# service is not started by default
start_service $MYSQL_SERVICE_NAME
+ elif is_ubuntu; then
+ # required since bind-address could have changed above
+ restart_service $MYSQL_SERVICE_NAME
fi
# Set the root password - only works the first time. For Ubuntu, we already
@@ -102,7 +108,7 @@
if is_ubuntu && [ "$MYSQL_SERVICE_NAME" == "mariadb" ]; then
local cmd_args="-uroot -p$DATABASE_PASSWORD "
else
- local cmd_args="-uroot -p$DATABASE_PASSWORD -h127.0.0.1 "
+ local cmd_args="-uroot -p$DATABASE_PASSWORD -h$SERVICE_LOCAL_HOST "
fi
# In mariadb e.g. on Ubuntu socket plugin is used for authentication
@@ -119,9 +125,7 @@
# Now update ``my.cnf`` for some local needs and restart the mysql service
- # Change bind-address from localhost (127.0.0.1) to any (::) and
- # set default db type to InnoDB
- iniset -sudo $my_conf mysqld bind-address "$(ipv6_unquote $SERVICE_LISTEN_ADDRESS)"
+ # Set default db type to InnoDB
iniset -sudo $my_conf mysqld sql_mode TRADITIONAL
iniset -sudo $my_conf mysqld default-storage-engine InnoDB
iniset -sudo $my_conf mysqld max_connections 1024