Refactor Apache httpd setup

All Apache httpd setup has been moved to a new helper script,
kolla_httpd_setup. This includes the existing clean of /run/httpd,
/var/run/httpd, /tmp/httpd etc.

Horizon has an additional bit of Apache config for Debian/binary, which
has been kept in extend_start.sh for horizon.

Change-Id: Ia2af74b69c151db0bd7e452460b0babcee50b282
Related: blueprint centos-rhel-8
This commit is contained in:
Mark Goddard 2019-12-10 11:51:51 +00:00
parent 5368359835
commit 8484190e77
26 changed files with 61 additions and 276 deletions

View File

@ -1,19 +1,10 @@
#!/bin/bash
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
aodh-dbsync
exit 0
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -7,16 +7,4 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
exit 0
fi
# Assume the service runs on top of Apache when user is root
if [[ "$(whoami)" == 'root' ]]; then
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -441,9 +441,9 @@ COPY set_configs.py /usr/local/bin/kolla_set_configs
{% if distro_python_version.startswith('3') %}
RUN sed -i -e "s+#\!/usr/bin/env python+#\!/usr/bin/env python3+g" /usr/local/bin/kolla_set_configs
{% endif %}
COPY start.sh /usr/local/bin/kolla_start
COPY copy_cacerts.sh /usr/local/bin/kolla_copy_cacerts
COPY httpd_setup.sh /usr/local/bin/kolla_httpd_setup
COPY sudoers /etc/sudoers
COPY curlrc /root/.curlrc
@ -461,7 +461,7 @@ ENTRYPOINT ["dumb-init", "--single-child", "--"]
{% endif %}
RUN touch /usr/local/bin/kolla_extend_start \
&& chmod 755 /usr/local/bin/kolla_start /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_set_configs /usr/local/bin/kolla_copy_cacerts \
&& chmod 755 /usr/local/bin/kolla_start /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_set_configs /usr/local/bin/kolla_copy_cacerts /usr/local/bin/kolla_httpd_setup \
&& chmod 440 /etc/sudoers \
&& mkdir -p /var/log/kolla \
&& chown :kolla /var/log/kolla \

View File

@ -0,0 +1,18 @@
#!/bin/bash
# This script performs setup necessary to run the Apache httpd web server.
# It should be sourced rather than executed as environment variables are set.
# Assume the service runs on top of Apache httpd when user is root.
if [[ "$(whoami)" == 'root' ]]; then
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
fi

View File

@ -17,16 +17,4 @@ if [[ "${!KOLLA_OSM[@]}" ]]; then
exit 0
fi
# Assume the service runs on top of Apache when user is root
if [[ "$(whoami)" == 'root' ]]; then
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -1,16 +1,5 @@
#!/bin/bash
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
@ -18,3 +7,5 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
cloudkitty-storage-init
exit 0
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -1,19 +1,10 @@
#!/bin/bash
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
sudo -H -u gnocchi gnocchi-upgrade --log-file /var/log/kolla/gnocchi/gnocchi-upgrade.log
exit 0
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -13,3 +13,5 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
fi
exit 0
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -7,18 +7,4 @@ if [[ $(stat -c %a /var/log/kolla/heat) != "755" ]]; then
chmod 755 /var/log/kolla/heat
fi
# Assume the service runs on top of Apache when user is root
if [[ "$(whoami)" == 'root' ]]; then
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
fi
. /usr/local/bin/kolla_heat_extend_start

View File

@ -355,21 +355,6 @@ config_watcher_dashboard
config_zaqar_dashboard
config_zun_dashboard
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
if [[ "${KOLLA_BASE_DISTRO}" == "debian" ]] && [[ ${KOLLA_INSTALL_TYPE} == "binary" ]]; then
APACHE_RUN_GROUP=horizon
APACHE_RUN_USER=horizon
fi
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
if settings_changed; then
${MANAGE_PY} collectstatic --noinput --clear
${MANAGE_PY} compress --force
@ -389,3 +374,10 @@ fi
if [[ -f ${SITE_PACKAGES}/openstack_dashboard/local/.secret_key_store ]] && [[ $(stat -c %U ${SITE_PACKAGES}/openstack_dashboard/local/.secret_key_store) != "horizon" ]]; then
chown horizon ${SITE_PACKAGES}/openstack_dashboard/local/.secret_key_store
fi
. /usr/local/bin/kolla_httpd_setup
if [[ "${KOLLA_BASE_DISTRO}" == "debian" ]] && [[ ${KOLLA_INSTALL_TYPE} == "binary" ]]; then
APACHE_RUN_GROUP=horizon
APACHE_RUN_USER=horizon
fi

View File

@ -18,16 +18,4 @@ if [[ "${!KOLLA_OSM[@]}" ]]; then
exit 0
fi
# Assume the service runs on top of Apache when user is root
if [[ "$(whoami)" == 'root' ]]; then
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -40,13 +40,4 @@ if [[ "${ironic_arch}" =~ aarch64 ]]; then
fi
fi
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -1,16 +1,5 @@
#!/bin/bash
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
# Create log dir for Keystone logs
KEYSTONE_LOG_DIR="/var/log/kolla/keystone"
if [[ ! -d "${KEYSTONE_LOG_DIR}" ]]; then
@ -56,4 +45,6 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
exit 0
fi
. /usr/local/bin/kolla_httpd_setup
ARGS="-DFOREGROUND"

View File

@ -8,16 +8,4 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
exit 0
fi
# Assume the service runs on top of Apache when user is root
if [[ "$(whoami)" == 'root' ]]; then
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -1,19 +1,10 @@
#!/bin/bash
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
masakari-manage db sync
exit 0
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -8,16 +8,4 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
exit 0
fi
# Assume the service runs on top of Apache when user is root
if [[ "$(whoami)" == 'root' ]]; then
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -9,17 +9,6 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
exit 0
fi
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
# When Apache first starts it writes out the custom log files with root
# ownership. This later prevents the Monasca API (which runs under the
# 'monasca' user) from updating them. To avoid this we create the log
@ -33,3 +22,5 @@ for LOG_TYPE in error access; do
chown monasca:kolla ${MONASCA_API_LOG_DIR}/${SERVICE}-${LOG_TYPE}.log
fi
done
. /usr/local/bin/kolla_httpd_setup

View File

@ -2,17 +2,6 @@
SERVICE="monasca-log-api"
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
# When Apache first starts it writes out the custom log files with root
# ownership. This later prevents the Monasca Log API (which runs under the
# 'monasca' user) from updating them. To avoid this we create the log
@ -26,3 +15,5 @@ for LOG_TYPE in error access; do
chown monasca:kolla ${MONASCA_LOG_API_LOG_DIR}/${SERVICE}-${LOG_TYPE}.log
fi
done
. /usr/local/bin/kolla_httpd_setup

View File

@ -24,16 +24,4 @@ if [[ "${!KOLLA_OSM[@]}" ]]; then
exit 0
fi
# Assume the service runs on top of Apache when user is root
if [[ "$(whoami)" == 'root' ]]; then
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -7,16 +7,4 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
exit 0
fi
# Assume the service runs on top of Apache when user is root
if [[ "$(whoami)" == 'root' ]]; then
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -1,19 +1,10 @@
#!/bin/bash
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
panko-dbsync
exit 0
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -20,13 +20,4 @@ if [[ "${!KOLLA_OSM[@]}" ]]; then
exit 0
fi
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -1,19 +1,10 @@
#!/bin/bash
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
qinling-db-manage upgrade head
exit 0
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -1,17 +1,8 @@
#!/bin/bash
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
vitrage-dbsync
exit 0
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -1,15 +1,3 @@
#!/bin/bash
# Assume the service runs on top of Apache when user is root
if [[ "$(whoami)" == 'root' ]]; then
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
fi
. /usr/local/bin/kolla_httpd_setup

View File

@ -1,19 +1,10 @@
#!/bin/bash
# NOTE(pbourke): httpd will not clean up after itself in some cases which
# results in the container not being able to restart. (bug #1489676, 1557036)
if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
# Loading Apache2 ENV variables
. /etc/apache2/envvars
install -d /var/run/apache2/
rm -rf /var/run/apache2/*
else
rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
fi
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
zun-db-manage upgrade
exit 0
fi
. /usr/local/bin/kolla_httpd_setup