From d935f2da68e1fd6952c9e2c2f75152dcde5d87d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 17 Feb 2016 14:47:57 +0100 Subject: [PATCH] Make Heka collect Magnum logs Partially implements: blueprint heka Change-Id: I91a977c6a3632c570f7a6054c8de3f5e3cb6932c --- ansible/roles/common/templates/heka-openstack.toml.j2 | 2 +- ansible/roles/common/templates/rsyslog.conf.j2 | 6 ------ ansible/roles/magnum/tasks/bootstrap.yml | 4 +++- ansible/roles/magnum/tasks/start.yml | 4 ++-- ansible/roles/magnum/templates/magnum.conf.j2 | 3 +-- docker/magnum/magnum-api/extend_start.sh | 7 +++++++ docker/magnum/magnum-base/Dockerfile.j2 | 9 ++++++--- docker/magnum/magnum-base/extend_start.sh | 8 ++++++++ 8 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 docker/magnum/magnum-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 2c8bbbdeec..b0cb8ebdd4 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)/(?P.*)\.log' +file_match = '(?Pnova|glance|keystone|neutron|cinder|heat|murano|magnum)/(?P.*)\.log' differentiator = ["Service", "_", "Program"] diff --git a/ansible/roles/common/templates/rsyslog.conf.j2 b/ansible/roles/common/templates/rsyslog.conf.j2 index be49a5ccb7..850cfdca5b 100644 --- a/ansible/roles/common/templates/rsyslog.conf.j2 +++ b/ansible/roles/common/templates/rsyslog.conf.j2 @@ -7,12 +7,6 @@ $KLogPermitNonKernelFacility on $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat $RepeatedMsgReduction on -$template MagnumApiFile,"/var/log/magnum/magnum-api.log" -:syslogtag,contains,"magnum-api" ?MagnumApiFile - -$template MagnumConductorFile,"/var/log/magnum/magnum-conductor.log" -:syslogtag,contains,"magnum-conductor" ?MagnumConductorFile - $template DynFile,"/var/log/syslog.log" *.* { ?DynFile diff --git a/ansible/roles/magnum/tasks/bootstrap.yml b/ansible/roles/magnum/tasks/bootstrap.yml index 21a4f9698f..ac33dc4a32 100644 --- a/ansible/roles/magnum/tasks/bootstrap.yml +++ b/ansible/roles/magnum/tasks/bootstrap.yml @@ -48,7 +48,9 @@ BOOTSTRAP: name: "bootstrap_magnum" restart_policy: "never" - volumes: "{{ node_config_directory }}/magnum-api/:{{ container_config_directory }}/:ro" + volumes: + - "{{ node_config_directory }}/magnum-api/:{{ container_config_directory }}/:ro" + - "kolla_logs:/var/log/kolla/" run_once: True delegate_to: "{{ groups['magnum-api'][0] }}" when: database_created diff --git a/ansible/roles/magnum/tasks/start.yml b/ansible/roles/magnum/tasks/start.yml index 51b7136842..f98afadf71 100644 --- a/ansible/roles/magnum/tasks/start.yml +++ b/ansible/roles/magnum/tasks/start.yml @@ -7,7 +7,7 @@ name: "magnum_api" volumes: - "{{ node_config_directory }}/magnum-api/:{{ container_config_directory }}/:ro" - - "rsyslog_socket:/var/lib/kolla/rsyslog/" + - "kolla_logs:/var/log/kolla/" when: inventory_hostname in groups['magnum-api'] - name: Starting magnum-conductor container @@ -18,5 +18,5 @@ name: "magnum_conductor" volumes: - "{{ node_config_directory }}/magnum-conductor/:{{ container_config_directory }}/:ro" - - "rsyslog_socket:/var/lib/kolla/rsyslog/" + - "kolla_logs:/var/log/kolla/" when: inventory_hostname in groups['magnum-conductor'] diff --git a/ansible/roles/magnum/templates/magnum.conf.j2 b/ansible/roles/magnum/templates/magnum.conf.j2 index 6a25720649..d55d713f41 100644 --- a/ansible/roles/magnum/templates/magnum.conf.j2 +++ b/ansible/roles/magnum/templates/magnum.conf.j2 @@ -1,8 +1,7 @@ [DEFAULT] debug = {{ magnum_logging_debug }} -use_syslog = true -syslog_log_facility = LOG_LOCAL0 +log_dir = /var/log/kolla/magnum {% if service_name == 'magnum-api' %} [api] diff --git a/docker/magnum/magnum-api/extend_start.sh b/docker/magnum/magnum-api/extend_start.sh index 0f92f6e7bf..d9922522be 100644 --- a/docker/magnum/magnum-api/extend_start.sh +++ b/docker/magnum/magnum-api/extend_start.sh @@ -1,5 +1,12 @@ #!/bin/bash +if [[ ! -d "/var/log/kolla/magnum" ]]; then + mkdir -p /var/log/kolla/magnum +fi +if [[ $(stat -c %a /var/log/kolla/magnum) != "755" ]]; then + chmod 755 /var/log/kolla/magnum +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 diff --git a/docker/magnum/magnum-base/Dockerfile.j2 b/docker/magnum/magnum-base/Dockerfile.j2 index e29f1e06de..f57cc6df60 100644 --- a/docker/magnum/magnum-base/Dockerfile.j2 +++ b/docker/magnum/magnum-base/Dockerfile.j2 @@ -15,10 +15,13 @@ ADD magnum-base-archive /magnum-base-source RUN ln -s magnum-base-source/* magnum \ && useradd --user-group magnum \ && /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt /magnum \ - && mkdir -p /etc/magnum /var/log/magnum /home/magnum \ + && mkdir -p /etc/magnum /home/magnum \ && cp -r /magnum/etc/magnum/* /etc/magnum \ - && chown -R magnum: /etc/magnum /var/log/magnum /home/magnum + && chown -R magnum: /etc/magnum /home/magnum {% endif %} -RUN usermod -a -G kolla magnum +COPY extend_start.sh /usr/local/bin/kolla_extend_start + +RUN usermod -a -G kolla magnum \ + && chmod 755 /usr/local/bin/kolla_extend_start diff --git a/docker/magnum/magnum-base/extend_start.sh b/docker/magnum/magnum-base/extend_start.sh new file mode 100644 index 0000000000..0e91c4c6f8 --- /dev/null +++ b/docker/magnum/magnum-base/extend_start.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [[ ! -d "/var/log/kolla/magnum" ]]; then + mkdir -p /var/log/kolla/magnum +fi +if [[ $(stat -c %a /var/log/kolla/magnum) != "755" ]]; then + chmod 755 /var/log/kolla/magnum +fi