summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Szumski <doug@stackhpc.com>2018-04-03 13:29:34 +0100
committerDoug Szumski <doug@stackhpc.com>2018-06-08 16:06:14 +0100
commit14e1aff964f72a34b93d74727f3b14b5e89d62ca (patch)
tree705237f66ea965206eef6cdebbd6bcb324245166
parent91f5cca1863bb54695774a892c83ccb2ffaf9006 (diff)
Update Monasca base and API images
* Support deploying APIs via Apache + mod_wsgi * Include InfluxDB client so that the Monasca API can talk to InfluxDB. Support for Cassandra can be added in a later commit. Change-Id: If71db99d4731967e814c5263f2c2d6f90391c2a6 Partially-Implements: blueprint monasca-containers
Notes
Notes (review): Code-Review+2: Mark Goddard <mark@stackhpc.com> Code-Review+1: Liping Mao <limao@cisco.com> Code-Review+2: Eduardo Gonzalez <dabarren@gmail.com> Code-Review+2: Jeffrey Zhang <jeffrey.zhang@99cloud.net> Workflow+1: Eduardo Gonzalez <dabarren@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 12 Jun 2018 11:55:52 +0000 Reviewed-on: https://review.openstack.org/559359 Project: openstack/kolla Branch: refs/heads/master
-rw-r--r--docker/kolla-toolbox/Dockerfile.j21
-rw-r--r--docker/monasca/monasca-api/Dockerfile.j218
-rw-r--r--docker/monasca/monasca-api/extend_start.sh42
-rw-r--r--docker/monasca/monasca-base/Dockerfile.j231
-rw-r--r--docker/monasca/monasca-base/extend_start.sh13
-rw-r--r--docker/monasca/monasca-log-api/Dockerfile.j24
-rw-r--r--docker/monasca/monasca-log-api/extend_start.sh27
7 files changed, 127 insertions, 9 deletions
diff --git a/docker/kolla-toolbox/Dockerfile.j2 b/docker/kolla-toolbox/Dockerfile.j2
index d5647f9..0fc920a 100644
--- a/docker/kolla-toolbox/Dockerfile.j2
+++ b/docker/kolla-toolbox/Dockerfile.j2
@@ -80,6 +80,7 @@ ENV PATH {{ virtualenv_path }}/bin:$PATH
80{% set kolla_toolbox_pip_packages = [ 80{% set kolla_toolbox_pip_packages = [
81 'ansible==2.2.0.0', 81 'ansible==2.2.0.0',
82 '"cmd2<0.9.0"', 82 '"cmd2<0.9.0"',
83 'influxdb',
83 'MySQL-python', 84 'MySQL-python',
84 'os-client-config==1.29.0', 85 'os-client-config==1.29.0',
85 'pbr==4.0.0', 86 'pbr==4.0.0',
diff --git a/docker/monasca/monasca-api/Dockerfile.j2 b/docker/monasca/monasca-api/Dockerfile.j2
index a66c548..e9f7b52 100644
--- a/docker/monasca/monasca-api/Dockerfile.j2
+++ b/docker/monasca/monasca-api/Dockerfile.j2
@@ -12,9 +12,21 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
12 12
13{% elif install_type == 'source' %} 13{% elif install_type == 'source' %}
14 14
15 {% if base_distro in ['centos', 'oraclelinux', 'rhel'] %}
16 {% set monasca_api_packages = [
17 'mariadb',
18 ] %}
19 {% elif base_distro in ['debian', 'ubuntu'] %}
20 {% set monasca_api_packages = [
21 'mariadb-client',
22 ] %}
23 {% endif %}
24{{ macros.install_packages(monasca_api_packages | customizable("packages")) }}
25
15ADD monasca-api-archive /monasca-api-source 26ADD monasca-api-archive /monasca-api-source
16 27
17{% set monasca_api_pip_packages = [ 28{% set monasca_api_pip_packages = [
29 'influxdb',
18 '/monasca-api' 30 '/monasca-api'
19] %} 31] %}
20 32
@@ -23,9 +35,9 @@ RUN ln -s monasca-api-source/* monasca-api \
23 35
24{% endif %} 36{% endif %}
25 37
38COPY extend_start.sh /usr/local/bin/kolla_monasca_extend_start
39RUN chmod 755 /usr/local/bin/kolla_monasca_extend_start
40
26{% block monasca_api_footer %}{% endblock %} 41{% block monasca_api_footer %}{% endblock %}
27 42
28{% block footer %}{% endblock %} 43{% block footer %}{% endblock %}
29
30USER monasca
31
diff --git a/docker/monasca/monasca-api/extend_start.sh b/docker/monasca/monasca-api/extend_start.sh
new file mode 100644
index 0000000..6152e41
--- /dev/null
+++ b/docker/monasca/monasca-api/extend_start.sh
@@ -0,0 +1,42 @@
1#!/bin/bash
2
3SERVICE="monasca-api"
4
5# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
6# of the KOLLA_BOOTSTRAP variable being set, including empty.
7if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
8 # Set the database name in the monasca database schema
9 sed "s/USE \`mon\`;/USE \`${MONASCA_DATABASE_NAME}\`;/g" \
10 /monasca-api/devstack/files/schema/mon_mysql.sql > /tmp/mon_mysql.sql
11 # Load the schema
12 mysql --host=${MONASCA_DATABASE_ADDRESS} \
13 --port=${MONASCA_DATABASE_PORT} \
14 --user=${MONASCA_DATABASE_USER} \
15 --password=${MONASCA_DATABASE_PASSWORD} \
16 < /tmp/mon_mysql.sql
17 exit 0
18fi
19
20# NOTE(pbourke): httpd will not clean up after itself in some cases which
21# results in the container not being able to restart. (bug #1489676, 1557036)
22if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
23 # Loading Apache2 ENV variables
24 . /etc/apache2/envvars
25 rm -rf /var/run/apache2/*
26else
27 rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
28fi
29
30# When Apache first starts it writes out the custom log files with root
31# ownership. This later prevents the Monasca API (which runs under the
32# 'monasca' user) from updating them. To avoid this we create the log
33# files with the required permissions here, before Apache does.
34MONASCA_API_LOG_DIR="/var/log/kolla/monasca"
35for LOG_TYPE in error access; do
36 if [ ! -f "${MONASCA_API_LOG_DIR}/${SERVICE}-${LOG_TYPE}.log" ]; then
37 touch ${MONASCA_API_LOG_DIR}/${SERVICE}-${LOG_TYPE}.log
38 fi
39 if [[ $(stat -c %U:%G ${MONASCA_API_LOG_DIR}/${SERVICE}-${LOG_TYPE}.log) != "monasca:kolla" ]]; then
40 chown monasca:kolla ${MONASCA_API_LOG_DIR}/${SERVICE}-${LOG_TYPE}.log
41 fi
42done
diff --git a/docker/monasca/monasca-base/Dockerfile.j2 b/docker/monasca/monasca-base/Dockerfile.j2
index 1306b57..bdf5e14 100644
--- a/docker/monasca/monasca-base/Dockerfile.j2
+++ b/docker/monasca/monasca-base/Dockerfile.j2
@@ -14,8 +14,37 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
14 14
15{% elif install_type == 'source' %} 15{% elif install_type == 'source' %}
16 16
17RUN mkdir -p /etc/monasca \ 17 {% if base_distro in ['centos', 'oraclelinux', 'rhel'] %}
18 {% set monasca_base_packages = [
19 'httpd',
20 'mod_ssl',
21 'mod_wsgi'
22 ] %}
23
24{{ macros.install_packages(monasca_base_packages | customizable("packages")) }}
25RUN sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf \
26 && sed -i -r 's,^(Listen 443),#\1,' /etc/httpd/conf.d/ssl.conf
27 {% elif base_distro in ['debian', 'ubuntu'] %}
28
29 {% set monasca_base_packages = [
30 'apache2',
31 'libapache2-mod-wsgi',
32 ] %}
33
34{{ macros.install_packages(monasca_base_packages | customizable("packages")) }}
35RUN truncate -s 0 /etc/apache2/ports.conf
36
37 {% endif %}
38
39{% block monasca_source_install %}
40
41{% set monasca_base_pip_packages = [
42] %}
43
44RUN {{ macros.install_pip(monasca_base_pip_packages | customizable("pip_packages")) }} \
45 && mkdir -p /etc/monasca \
18 && chown -R monasca: /etc/monasca 46 && chown -R monasca: /etc/monasca
47{% endblock %}
19 48
20{% endif %} 49{% endif %}
21 50
diff --git a/docker/monasca/monasca-base/extend_start.sh b/docker/monasca/monasca-base/extend_start.sh
index c224563..77e835d 100644
--- a/docker/monasca/monasca-base/extend_start.sh
+++ b/docker/monasca/monasca-base/extend_start.sh
@@ -1,10 +1,15 @@
1#!/bin/bash 1#!/bin/bash
2 2
3if [[ ! -d "/var/log/kolla/monasca" ]]; then 3# Create log directory, with appropriate permissions
4 mkdir -p /var/log/kolla/monasca 4MONASCA_LOG_DIR="/var/log/kolla/monasca"
5if [[ ! -d "$MONASCA_LOG_DIR" ]]; then
6 mkdir -p $MONASCA_LOG_DIR
5fi 7fi
6if [[ $(stat -c %a /var/log/kolla/monasca) != "755" ]]; then 8if [[ $(stat -c %U:%G ${MONASCA_LOG_DIR}) != "monasca:kolla" ]]; then
7 chmod 755 /var/log/kolla/monasca 9 chown monasca:kolla ${MONASCA_LOG_DIR}
10fi
11if [[ $(stat -c %a ${MONASCA_LOG_DIR}) != "755" ]]; then
12 chmod 755 ${MONASCA_LOG_DIR}
8fi 13fi
9 14
10. /usr/local/bin/kolla_monasca_extend_start 15. /usr/local/bin/kolla_monasca_extend_start
diff --git a/docker/monasca/monasca-log-api/Dockerfile.j2 b/docker/monasca/monasca-log-api/Dockerfile.j2
index 72d3d30..94d4940 100644
--- a/docker/monasca/monasca-log-api/Dockerfile.j2
+++ b/docker/monasca/monasca-log-api/Dockerfile.j2
@@ -18,9 +18,11 @@ RUN ln -s monasca-log-api-source/* monasca-log \
18 18
19{% endif %} 19{% endif %}
20 20
21COPY extend_start.sh /usr/local/bin/kolla_monasca_extend_start
22RUN chmod 755 /usr/local/bin/kolla_monasca_extend_start
23
21{% block monasca_log_api_footer %}{% endblock %} 24{% block monasca_log_api_footer %}{% endblock %}
22 25
23{% block footer %}{% endblock %} 26{% block footer %}{% endblock %}
24 27
25USER monasca
26 28
diff --git a/docker/monasca/monasca-log-api/extend_start.sh b/docker/monasca/monasca-log-api/extend_start.sh
new file mode 100644
index 0000000..bcccdf1
--- /dev/null
+++ b/docker/monasca/monasca-log-api/extend_start.sh
@@ -0,0 +1,27 @@
1#!/bin/bash
2
3SERVICE="monasca-log-api"
4
5# NOTE(pbourke): httpd will not clean up after itself in some cases which
6# results in the container not being able to restart. (bug #1489676, 1557036)
7if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
8 # Loading Apache2 ENV variables
9 . /etc/apache2/envvars
10 rm -rf /var/run/apache2/*
11else
12 rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
13fi
14
15# When Apache first starts it writes out the custom log files with root
16# ownership. This later prevents the Monasca Log API (which runs under the
17# 'monasca' user) from updating them. To avoid this we create the log
18# files with the required permissions here, before Apache does.
19MONASCA_LOG_API_LOG_DIR="/var/log/kolla/monasca"
20for LOG_TYPE in error access; do
21 if [ ! -f "${MONASCA_LOG_API_LOG_DIR}/${SERVICE}-${LOG_TYPE}.log" ]; then
22 touch ${MONASCA_LOG_API_LOG_DIR}/${SERVICE}-${LOG_TYPE}.log
23 fi
24 if [[ $(stat -c %U:%G ${MONASCA_LOG_API_LOG_DIR}/${SERVICE}-${LOG_TYPE}.log) != "monasca:kolla" ]]; then
25 chown monasca:kolla ${MONASCA_LOG_API_LOG_DIR}/${SERVICE}-${LOG_TYPE}.log
26 fi
27done