repair gnocchi dockerfile

1. Add the missing packages in the gnocchi image
   packages: lz4 sqlalchemy_utils gnocchiclient

2. gnocchi config path is error
   gnocchi config path is /gnocchi/etc/gnocchi

3. gnocchi sync db command is error
   sync db command is: gnocchi-upgrade
   Reference link: http://docs.openstack.org/developer/gnocchi/install.html

4. gnocchi log directory is /var/log/kolla/gnocchi

5. Add gnocchi-api running as a mod_wsgi
   Reference link: http://docs.openstack.org/developer/gnocchi/running.html

6. Add gnocchi sudoers file

Closes-Bug: #1607332

Change-Id: Id3aded82706ffd204373c97a020980d0d9b72663
This commit is contained in:
zhubingbing 2016-07-28 14:28:20 +00:00
parent 69af20852a
commit 55b184a865
6 changed files with 92 additions and 15 deletions

View File

@ -21,5 +21,3 @@ RUN chmod 755 /usr/local/bin/kolla_gnocchi_extend_start
{% block gnocchi_api_footer %}{% endblock %} {% block gnocchi_api_footer %}{% endblock %}
{% block footer %}{% endblock %} {% block footer %}{% endblock %}
{{ include_footer }} {{ include_footer }}
USER gnocchi

View File

@ -1,8 +1,18 @@
#!/bin/bash #!/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
source /etc/apache2/envvars
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 # Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty. # of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
gnocchi-manage db_sync gnocchi-upgrade --logfile /var/log/kolla/gnocchi/gnocchi-upgrade.log
exit 0 exit 0
fi fi

View File

@ -4,24 +4,78 @@ MAINTAINER {{ maintainer }}
{% import "macros.j2" as macros with context %} {% import "macros.j2" as macros with context %}
{% if install_type == 'binary' %} {% if install_type == 'binary' %}
{% if base_distro in ['fedora', 'centos', 'oraclelinux', 'rhel'] %}
{% set gnocchi_base_packages = [
'openstack-gnocchi-common',
'python-gnocchiclient',
'httpd',
'mod_wsgi',
'python-ldappool'
] %}
{% if base_distro in ['centos', 'fedora', 'oraclelinux', 'rhel'] %}
{% set gnocchi_base_packages = ['openstack-gnocchi-common'] %}
{% elif base_distro in ['ubuntu'] %}
{% set gnocchi_base_packages = ['gnocchi-common'] %}
{% endif %}
{{ macros.install_packages(gnocchi_base_packages | customizable("packages")) }} {{ macros.install_packages(gnocchi_base_packages | customizable("packages")) }}
RUN mkdir -p /var/www/cgi-bin/gnocchi \
&& cp -a /usr/lib/python2.7/site-packages/gnocchi/rest/app.wsgi /var/www/cgi-bin/gnocchi/app \
&& sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf
{% elif base_distro in ['ubuntu'] %}
{% set gnocchi_base_packages = [
'gnocchi-common',
'apache2',
'libapache2-mod-wsgi',
'python-ldappool'
] %}
{{ macros.install_packages(gnocchi_base_packages | customizable("packages")) }}
RUN mkdir -p /var/www/cgi-bin/gnocchi \
&& cp -a /usr/share/gnocchi-common/app.wsgi /var/www/cgi-bin/gnocchi/app \
&& echo > /etc/apache2/ports.conf
{% endif %}
{% elif install_type == 'source' %} {% elif install_type == 'source' %}
{% if base_distro in ['fedora', 'centos', 'oraclelinux', 'rhel'] %}
{% set gnocchi_base_packages = [
'httpd',
'mod_wsgi',
'python-ldappool'
] %}
{{ macros.install_packages(gnocchi_base_packages | customizable("packages")) }}
RUN mkdir -p /var/www/cgi-bin/gnocchi \
&& sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf
{% elif base_distro in ['ubuntu', 'debian'] %}
{% set gnocchi_base_packages = [
'apache2',
'libapache2-mod-wsgi',
'python-ldappool'
] %}
{{ macros.install_packages(gnocchi_base_packages | customizable("packages")) }}
RUN echo > /etc/apache2/ports.conf
{% endif %}
ADD gnocchi-base-archive /gnocchi-base-source ADD gnocchi-base-archive /gnocchi-base-source
RUN ln -s gnocchi-base-source/* gnocchi \ RUN ln -s gnocchi-base-source/* gnocchi \
&& useradd --user-group gnocchi \ && useradd --user-group gnocchi \
&& /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt tooz /gnocchi \ && /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt tooz lz4 sqlalchemy_utils gnocchiclient /gnocchi \
&& mkdir -p /etc/gnocchi /var/log/gnocchi /home/gnocchi \ && mkdir -p /etc/gnocchi /var/log/kolla/gnocchi /home/gnocchi /var/www/cgi-bin/gnocchi \
&& cp -r /gnocchi/etc/* /etc/gnocchi/ \ && cp -r /gnocchi/etc/gnocchi/* /etc/gnocchi/ \
&& chown -R gnocchi: /etc/gnocchi /var/log/gnocchi /home/gnocchi && cp /gnocchi/gnocchi/rest/app.wsgi /var/www/cgi-bin/gnocchi/ \
&& chown -R gnocchi: /etc/gnocchi /var/log/kolla/gnocchi /var/www/cgi-bin/gnocchi
{% endif %} {% endif %}
RUN usermod -a -G kolla gnocchi COPY extend_start.sh /usr/local/bin/kolla_extend_start
COPY gnocchi_sudoers /etc/sudoers.d/kolla_gnocchi_sudoers
RUN usermod -a -G kolla gnocchi \
&& chmod 750 /etc/sudoers.d \
&& chmod 640 /etc/sudoers.d/kolla_gnocchi_sudoers \
&& chmod 755 /var/www/cgi-bin/gnocchi \
&& touch /usr/local/bin/kolla_gnocchi_extend_start \
&& chmod 755 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_gnocchi_extend_start
{% block gnocchi_base_footer %}{% endblock %}

View File

@ -0,0 +1,15 @@
#!/bin/bash
# Create log dir for Gnocchi logs
GNOCCHI_LOG_DIR="/var/log/kolla/gnocchi"
if [[ ! -d "${GNOCCHI_LOG_DIR}" ]]; then
mkdir -p ${GNOCCHI_LOG_DIR}
fi
if [[ $(stat -c %U:%G ${GNOCCHI_LOG_DIR}) != "gnocchi:kolla" ]]; then
chown gnocchi:kolla ${GNOCCHI_LOG_DIR}
fi
if [[ $(stat -c %a ${GNOCCHI_LOG_DIR}) != "755" ]]; then
chmod 755 ${GNOCCHI_LOG_DIR}
fi
source /usr/local/bin/kolla_gnocchi_extend_start

View File

@ -0,0 +1 @@
%kolla ALL=(root) NOPASSWD: /usr/bin/chown -R gnocchi\: /var/lib/gnocchi/, /bin/chown -R gnocchi\: /var/lib/gnocchi/

View File

@ -80,8 +80,7 @@ class BuildTestCentosBinary(BuildTest, base.BaseTestCase):
class BuildTestCentosSource(BuildTest, base.BaseTestCase): class BuildTestCentosSource(BuildTest, base.BaseTestCase):
excluded_images = ["gnocchi-base", excluded_images = ["mistral-base"]
"mistral-base"]
def setUp(self): def setUp(self):
super(BuildTestCentosSource, self).setUp() super(BuildTestCentosSource, self).setUp()