Browse Source

Merge "Update Monasca base and API images"

tags/7.0.0.0b3
Zuul 11 months ago
parent
commit
858c5f0377

+ 1
- 0
docker/kolla-toolbox/Dockerfile.j2 View File

@@ -80,6 +80,7 @@ ENV PATH {{ virtualenv_path }}/bin:$PATH
80 80
 {% set kolla_toolbox_pip_packages = [
81 81
         'ansible==2.2.0.0',
82 82
         '"cmd2<0.9.0"',
83
+        'influxdb',
83 84
         'MySQL-python',
84 85
         'os-client-config==1.29.0',
85 86
         'pbr==4.0.0',

+ 15
- 3
docker/monasca/monasca-api/Dockerfile.j2 View File

@@ -12,9 +12,21 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
12 12
 
13 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
+
15 26
 ADD monasca-api-archive /monasca-api-source
16 27
 
17 28
 {% set monasca_api_pip_packages = [
29
+    'influxdb',
18 30
     '/monasca-api'
19 31
 ] %}
20 32
 
@@ -23,9 +35,9 @@ RUN ln -s monasca-api-source/* monasca-api \
23 35
 
24 36
 {% endif %}
25 37
 
38
+COPY extend_start.sh /usr/local/bin/kolla_monasca_extend_start
39
+RUN chmod 755 /usr/local/bin/kolla_monasca_extend_start
40
+
26 41
 {% block monasca_api_footer %}{% endblock %}
27 42
 
28 43
 {% block footer %}{% endblock %}
29
-
30
-USER monasca
31
-

+ 42
- 0
docker/monasca/monasca-api/extend_start.sh View File

@@ -0,0 +1,42 @@
1
+#!/bin/bash
2
+
3
+SERVICE="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.
7
+if [[ "${!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
18
+fi
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)
22
+if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
23
+    # Loading Apache2 ENV variables
24
+    . /etc/apache2/envvars
25
+    rm -rf /var/run/apache2/*
26
+else
27
+    rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
28
+fi
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.
34
+MONASCA_API_LOG_DIR="/var/log/kolla/monasca"
35
+for 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
42
+done

+ 30
- 1
docker/monasca/monasca-base/Dockerfile.j2 View File

@@ -14,8 +14,37 @@ RUN echo '{{ install_type }} not yet available for {{ base_distro }}' \
14 14
 
15 15
 {% elif install_type == 'source' %}
16 16
 
17
-RUN 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")) }}
25
+RUN 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")) }}
35
+RUN 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
+
44
+RUN {{ macros.install_pip(monasca_base_pip_packages | customizable("pip_packages")) }} \
45
+    && mkdir -p /etc/monasca \
18 46
     && chown -R monasca: /etc/monasca
47
+{% endblock %}
19 48
 
20 49
 {% endif %}
21 50
 

+ 9
- 4
docker/monasca/monasca-base/extend_start.sh View File

@@ -1,10 +1,15 @@
1 1
 #!/bin/bash
2 2
 
3
-if [[ ! -d "/var/log/kolla/monasca" ]]; then
4
-    mkdir -p /var/log/kolla/monasca
3
+# Create log directory, with appropriate permissions
4
+MONASCA_LOG_DIR="/var/log/kolla/monasca"
5
+if [[ ! -d "$MONASCA_LOG_DIR" ]]; then
6
+    mkdir -p $MONASCA_LOG_DIR
5 7
 fi
6
-if [[ $(stat -c %a /var/log/kolla/monasca) != "755" ]]; then
7
-    chmod 755 /var/log/kolla/monasca
8
+if [[ $(stat -c %U:%G ${MONASCA_LOG_DIR}) != "monasca:kolla" ]]; then
9
+    chown monasca:kolla ${MONASCA_LOG_DIR}
10
+fi
11
+if [[ $(stat -c %a ${MONASCA_LOG_DIR}) != "755" ]]; then
12
+    chmod 755 ${MONASCA_LOG_DIR}
8 13
 fi
9 14
 
10 15
 . /usr/local/bin/kolla_monasca_extend_start

+ 3
- 1
docker/monasca/monasca-log-api/Dockerfile.j2 View File

@@ -18,9 +18,11 @@ RUN ln -s monasca-log-api-source/* monasca-log \
18 18
 
19 19
 {% endif %}
20 20
 
21
+COPY extend_start.sh /usr/local/bin/kolla_monasca_extend_start
22
+RUN chmod 755 /usr/local/bin/kolla_monasca_extend_start
23
+
21 24
 {% block monasca_log_api_footer %}{% endblock %}
22 25
 
23 26
 {% block footer %}{% endblock %}
24 27
 
25
-USER monasca
26 28
 

+ 27
- 0
docker/monasca/monasca-log-api/extend_start.sh View File

@@ -0,0 +1,27 @@
1
+#!/bin/bash
2
+
3
+SERVICE="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)
7
+if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
8
+    # Loading Apache2 ENV variables
9
+    . /etc/apache2/envvars
10
+    rm -rf /var/run/apache2/*
11
+else
12
+    rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
13
+fi
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.
19
+MONASCA_LOG_API_LOG_DIR="/var/log/kolla/monasca"
20
+for 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
27
+done

Loading…
Cancel
Save