From 89d38770cebfdf537683c7a40ccc6c40ebd70e46 Mon Sep 17 00:00:00 2001 From: Jeffrey Zhang Date: Thu, 29 Sep 2016 01:14:19 +0800 Subject: [PATCH] Fix error in Gnocchi service * mount gnocchi volume for gnocchi-api and gnocchi-statsd * fix the failed of gnocchi-api * use gnocchi user when running gnocchi-upgrade * use the app.wsgi file in python path directly, rather than copy it to /var/www/cgi-bin/gnocchi/app file TrivialFix Change-Id: Ie026b8f44cd8e9703bf115cebb4e2d50b114a3a2 --- ansible/roles/gnocchi/tasks/start.yml | 2 ++ .../gnocchi/templates/wsgi-gnocchi.conf.j2 | 24 +++++++------------ docker/gnocchi/gnocchi-api/extend_start.sh | 2 +- docker/gnocchi/gnocchi-base/Dockerfile.j2 | 18 ++++++-------- 4 files changed, 18 insertions(+), 28 deletions(-) diff --git a/ansible/roles/gnocchi/tasks/start.yml b/ansible/roles/gnocchi/tasks/start.yml index 98d54241c6..d53ab979b5 100644 --- a/ansible/roles/gnocchi/tasks/start.yml +++ b/ansible/roles/gnocchi/tasks/start.yml @@ -19,6 +19,7 @@ name: "gnocchi_metricd" volumes: - "{{ node_config_directory }}/gnocchi-metricd/:{{ container_config_directory }}/:ro" + - "gnocchi:/var/lib/gnocchi/" - "kolla_logs:/var/log/kolla/" when: inventory_hostname in groups['gnocchi-metricd'] @@ -30,5 +31,6 @@ name: "gnocchi_statsd" volumes: - "{{ node_config_directory }}/gnocchi-statsd/:{{ container_config_directory }}/:ro" + - "gnocchi:/var/lib/gnocchi/" - "kolla_logs:/var/log/kolla/" when: inventory_hostname in groups['gnocchi-statsd'] diff --git a/ansible/roles/gnocchi/templates/wsgi-gnocchi.conf.j2 b/ansible/roles/gnocchi/templates/wsgi-gnocchi.conf.j2 index c6bc624c98..5d1317ec0d 100644 --- a/ansible/roles/gnocchi/templates/wsgi-gnocchi.conf.j2 +++ b/ansible/roles/gnocchi/templates/wsgi-gnocchi.conf.j2 @@ -3,23 +3,15 @@ Listen {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['addr - ## Vhost docroot - DocumentRoot "/var/www/cgi-bin/gnocchi" + ErrorLog "/var/log/kolla/gnocchi/gnocchi-api-error.log" + CustomLog "/var/log/kolla/gnocchi/gnocchi-api-access.log" combined + WSGIApplicationGroup %{GLOBAL} + WSGIDaemonProcess gnocchi group=gnocchi processes=5 threads=1 user=gnocchi python-path={{ python_path }} + WSGIProcessGroup gnocchi + WSGIScriptAlias / "{{ python_path }}/gnocchi/rest/app.wsgi" - ## Directories, there should at least be a declaration for /var/www/cgi-bin/gnocchi - - - Options Indexes FollowSymLinks MultiViews - AllowOverride None - Require all granted + + Require all granted - ## Logging - ErrorLog "/var/log/kolla/gnocchi/gnocchi_wsgi_error.log" - ServerSignature Off - CustomLog "/var/log/kolla/gnocchi/gnocchi_wsgi_access.log" combined - WSGIApplicationGroup %{GLOBAL} - WSGIDaemonProcess gnocchi group=gnocchi processes=2 threads=2 user=gnocchi - WSGIProcessGroup gnocchi - WSGIScriptAlias / "/var/www/cgi-bin/gnocchi/app" diff --git a/docker/gnocchi/gnocchi-api/extend_start.sh b/docker/gnocchi/gnocchi-api/extend_start.sh index ac06893c86..bda1170e1e 100644 --- a/docker/gnocchi/gnocchi-api/extend_start.sh +++ b/docker/gnocchi/gnocchi-api/extend_start.sh @@ -13,6 +13,6 @@ 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 - gnocchi-upgrade --logfile /var/log/kolla/gnocchi/gnocchi-upgrade.log + sudo -H -i -u gnocchi gnocchi-upgrade --create-legacy-resource-types --logfile /var/log/kolla/gnocchi/gnocchi-upgrade.log exit 0 fi diff --git a/docker/gnocchi/gnocchi-base/Dockerfile.j2 b/docker/gnocchi/gnocchi-base/Dockerfile.j2 index 32e5df6cb9..213a3a610d 100644 --- a/docker/gnocchi/gnocchi-base/Dockerfile.j2 +++ b/docker/gnocchi/gnocchi-base/Dockerfile.j2 @@ -17,9 +17,7 @@ MAINTAINER {{ maintainer }} ] %} {{ 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 +RUN sed -i -r 's,^(Listen 80),#\1,' /etc/httpd/conf/httpd.conf {% elif base_distro in ['ubuntu'] %} {% set gnocchi_base_packages = [ @@ -30,9 +28,7 @@ RUN mkdir -p /var/www/cgi-bin/gnocchi \ ] %} {{ 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 +RUN truncate -s 0 /etc/apache2/ports.conf {% endif %} {% elif install_type == 'source' %} @@ -55,7 +51,7 @@ RUN mkdir -p /var/www/cgi-bin/gnocchi \ ] %} {{ macros.install_packages(gnocchi_base_packages | customizable("packages")) }} -RUN echo > /etc/apache2/ports.conf +RUN truncate -s 0 /etc/apache2/ports.conf {% endif %} ADD gnocchi-base-archive /gnocchi-base-source @@ -63,10 +59,9 @@ ADD gnocchi-base-archive /gnocchi-base-source RUN ln -s gnocchi-base-source/* gnocchi \ && useradd --user-group gnocchi \ && /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt gnocchiclient /gnocchi[keystone,mysql,file] \ - && mkdir -p /etc/gnocchi /var/log/kolla/gnocchi /home/gnocchi /var/www/cgi-bin/gnocchi \ + && mkdir -p /etc/gnocchi /var/log/kolla/gnocchi /home/gnocchi \ && cp -r /gnocchi/etc/gnocchi/* /etc/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 + && chown -R gnocchi: /etc/gnocchi /var/log/kolla/gnocchi {% endif %} @@ -74,9 +69,10 @@ 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 \ + && mkdir -p /var/lib/gnocchi \ + && chown -R gnocchi: /var/lib/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