From a2fe38bba5ea3e89b380e6fa54aff7e17f9f1d76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 22 Feb 2016 09:15:23 -0800 Subject: [PATCH] Make Heka collect Mistral logs Partially implements: blueprint heka Change-Id: Ib6ac3228626360216c2c738ed601d61375b51675 --- ansible/roles/common/templates/heka-openstack.toml.j2 | 2 +- ansible/roles/mistral/tasks/bootstrap_service.yml | 4 +++- ansible/roles/mistral/tasks/start.yml | 6 +++--- ansible/roles/mistral/templates/mistral.conf.j2 | 6 ++++-- docker/mistral/mistral-api/Dockerfile.j2 | 4 ++-- docker/mistral/mistral-base/Dockerfile.j2 | 10 +++++++--- docker/mistral/mistral-base/extend_start.sh | 10 ++++++++++ 7 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 docker/mistral/mistral-base/extend_start.sh diff --git a/ansible/roles/common/templates/heka-openstack.toml.j2 b/ansible/roles/common/templates/heka-openstack.toml.j2 index b0cb8ebdd4..3649705b6d 100644 --- a/ansible/roles/common/templates/heka-openstack.toml.j2 +++ b/ansible/roles/common/templates/heka-openstack.toml.j2 @@ -6,5 +6,5 @@ filename = "lua_decoders/os_openstack_log.lua" type = "LogstreamerInput" decoder = "openstack_log_decoder" log_directory = "/var/log/kolla" -file_match = '(?Pnova|glance|keystone|neutron|cinder|heat|murano|magnum)/(?P.*)\.log' +file_match = '(?Pnova|glance|keystone|neutron|cinder|heat|murano|magnum|mistral)/(?P.*)\.log' differentiator = ["Service", "_", "Program"] diff --git a/ansible/roles/mistral/tasks/bootstrap_service.yml b/ansible/roles/mistral/tasks/bootstrap_service.yml index 538d850561..4ca55c8213 100644 --- a/ansible/roles/mistral/tasks/bootstrap_service.yml +++ b/ansible/roles/mistral/tasks/bootstrap_service.yml @@ -12,6 +12,8 @@ BOOTSTRAP: name: "bootstrap_mistral" restart_policy: "never" - volumes: "{{ node_config_directory }}/mistral-api/:{{ container_config_directory }}/:ro" + volumes: + - "{{ node_config_directory }}/mistral-api/:{{ container_config_directory }}/:ro" + - "kolla_logs:/var/log/kolla/" run_once: True delegate_to: "{{ groups['mistral-api'][0] }}" diff --git a/ansible/roles/mistral/tasks/start.yml b/ansible/roles/mistral/tasks/start.yml index 52677ccc1a..9987b8aaeb 100644 --- a/ansible/roles/mistral/tasks/start.yml +++ b/ansible/roles/mistral/tasks/start.yml @@ -7,7 +7,7 @@ image: "{{ mistral_engine_image_full }}" volumes: - "{{ node_config_directory }}/mistral-engine/:{{ container_config_directory }}/:ro" - - "rsyslog_socket:/var/lib/kolla/rsyslog/" + - "kolla_logs:/var/log/kolla/" when: inventory_hostname in groups['mistral-engine'] - name: Starting mistral-executor container @@ -18,7 +18,7 @@ image: "{{ mistral_executor_image_full }}" volumes: - "{{ node_config_directory }}/mistral-executor/:{{ container_config_directory }}/:ro" - - "rsyslog_socket:/var/lib/kolla/rsyslog/" + - "kolla_logs:/var/log/kolla/" when: inventory_hostname in groups['mistral-executor'] - name: Starting mistral-api container @@ -29,5 +29,5 @@ image: "{{ mistral_api_image_full }}" volumes: - "{{ node_config_directory }}/mistral-api/:{{ container_config_directory }}/:ro" - - "rsyslog_socket:/var/lib/kolla/rsyslog/" + - "kolla_logs:/var/log/kolla/" when: inventory_hostname in groups['mistral-api'] diff --git a/ansible/roles/mistral/templates/mistral.conf.j2 b/ansible/roles/mistral/templates/mistral.conf.j2 index 1c2f24c0a6..5a18367ef2 100644 --- a/ansible/roles/mistral/templates/mistral.conf.j2 +++ b/ansible/roles/mistral/templates/mistral.conf.j2 @@ -1,9 +1,11 @@ [DEFAULT] debug = {{ mistral_logging_debug }} +log_dir = /var/log/kolla/mistral -use_syslog = True -syslog_log_facility = LOG_LOCAL0 +# NOTE(elemoine): set use_stderr to False or the logs will also be sent to +# stderr and collected by Docker +use_stderr = False {% if service_name == 'mistral-api' %} bind_host = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} diff --git a/docker/mistral/mistral-api/Dockerfile.j2 b/docker/mistral/mistral-api/Dockerfile.j2 index 3e313ddef5..716ab07eb6 100644 --- a/docker/mistral/mistral-api/Dockerfile.j2 +++ b/docker/mistral/mistral-api/Dockerfile.j2 @@ -1,8 +1,8 @@ FROM {{ namespace }}/{{ image_prefix }}mistral-base:{{ tag }} MAINTAINER {{ maintainer }} -COPY extend_start.sh /usr/local/bin/kolla_extend_start -RUN chmod 755 /usr/local/bin/kolla_extend_start +COPY extend_start.sh /usr/local/bin/kolla_mistral_extend_start +RUN chmod 755 /usr/local/bin/kolla_mistral_extend_start {{ include_footer }} diff --git a/docker/mistral/mistral-base/Dockerfile.j2 b/docker/mistral/mistral-base/Dockerfile.j2 index fbcc7f3e84..6f37014f45 100644 --- a/docker/mistral/mistral-base/Dockerfile.j2 +++ b/docker/mistral/mistral-base/Dockerfile.j2 @@ -12,10 +12,14 @@ ADD mistral-base-archive /mistral-base-source RUN ln -s mistral-base-source/* mistral \ && useradd --user-group mistral \ && /var/lib/kolla/venv/bin/pip --no-cache-dir install /mistral \ - && mkdir -p /etc/mistral /var/log/mistral /home/mistral \ + && mkdir -p /etc/mistral /home/mistral \ && cp -r /mistral/etc/* /etc/mistral/ \ - && chown -R mistral: /etc/mistral /var/log/mistral /home/mistral + && chown -R mistral: /etc/mistral /home/mistral {% endif %} -RUN usermod -a -G kolla mistral +COPY extend_start.sh /usr/local/bin/kolla_extend_start + +RUN usermod -a -G kolla mistral \ + && touch /usr/local/bin/kolla_mistral_extend_start \ + && chmod 755 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_mistral_extend_start diff --git a/docker/mistral/mistral-base/extend_start.sh b/docker/mistral/mistral-base/extend_start.sh new file mode 100644 index 0000000000..f84c570c41 --- /dev/null +++ b/docker/mistral/mistral-base/extend_start.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +if [[ ! -d "/var/log/kolla/mistral" ]]; then + mkdir -p /var/log/kolla/mistral +fi +if [[ $(stat -c %a /var/log/kolla/mistral) != "755" ]]; then + chmod 755 /var/log/kolla/mistral +fi + +source /usr/local/bin/kolla_mistral_extend_start