From a2b130d6bacc58a28ed16bf42c4f325d027c2e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 11 Feb 2016 18:49:40 +0100 Subject: [PATCH] Make Heka collect Neutron logs Partially implements: blueprint heka Change-Id: I70e94f4ef7380c6f376a3066d7ddda042c703637 --- .../common/templates/heka-openstack.toml.j2 | 2 +- ansible/roles/common/templates/rsyslog.conf.j2 | 18 ------------------ ansible/roles/neutron/tasks/bootstrap.yml | 4 +++- ansible/roles/neutron/tasks/start.yml | 14 +++++++------- .../roles/neutron/templates/neutron.conf.j2 | 7 +++++-- docker/neutron/neutron-base/Dockerfile.j2 | 9 ++++++--- docker/neutron/neutron-base/extend_start.sh | 8 ++++++++ .../neutron-metadata-agent/extend_start.sh | 7 +++++++ docker/neutron/neutron-server/extend_start.sh | 7 +++++++ 9 files changed, 44 insertions(+), 32 deletions(-) create mode 100644 docker/neutron/neutron-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 ace78b71f3..db642dd156 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)/(?P.*)\.log' +file_match = '(?Pnova|glance|keystone|neutron)/(?P.*)\.log' differentiator = ["Service", "_", "Program"] diff --git a/ansible/roles/common/templates/rsyslog.conf.j2 b/ansible/roles/common/templates/rsyslog.conf.j2 index f7323c9d81..0809115219 100644 --- a/ansible/roles/common/templates/rsyslog.conf.j2 +++ b/ansible/roles/common/templates/rsyslog.conf.j2 @@ -16,24 +16,6 @@ $template HeatAPICfnFile,"/var/log/heat/heat-api-cfn.log" $template HeatEngineFile,"/var/log/heat/heat-engine.log" :syslogtag,contains,"heat-engine" ?HeatEngineFile -$template NeutronServerFile,"/var/log/neutron/neutron-server.log" -:syslogtag,contains,"neutron-server" ?NeutronServerFile - -$template NeutronOVSAgentFile,"/var/log/neutron/neutron-openvswitch-agent.log" -:syslogtag,contains,"neutron-openvswitch-agent" ?NeutronOVSAgentFile - -$template NeutronLinuxbrAgentFile,"/var/log/neutron/neutron-linuxbridge-agent.log" -:syslogtag,contains,"neutron-linuxbridge-agent" ?NeutronLinuxbrAgentFile - -$template NeutronDHCPAgentFile,"/var/log/neutron/neutron-dhcp-agent.log" -:syslogtag,contains,"neutron-dhcp-agent" ?NeutronDHCPAgentFile - -$template NeutronMetadataAgentFile,"/var/log/neutron/neutron-metadata-agent.log" -:syslogtag,contains,"neutron-metadata-agent" ?NeutronMetadataAgentFile - -$template NeutronL3AgentFile,"/var/log/neutron/neutron-l3-agent.log" -:syslogtag,contains,"neutron-l3-agent" ?NeutronL3AgentFile - $template CinderApiFile,"/var/log/cinder/cinder-api.log" :syslogtag,contains,"cinder-api" ?CinderApiFile diff --git a/ansible/roles/neutron/tasks/bootstrap.yml b/ansible/roles/neutron/tasks/bootstrap.yml index 9eba99be1b..45821fa681 100644 --- a/ansible/roles/neutron/tasks/bootstrap.yml +++ b/ansible/roles/neutron/tasks/bootstrap.yml @@ -48,7 +48,9 @@ BOOTSTRAP: name: "bootstrap_neutron" restart_policy: "never" - volumes: "{{ node_config_directory }}/neutron-server/:{{ container_config_directory }}/:ro" + volumes: + - "{{ node_config_directory }}/neutron-server/:{{ container_config_directory }}/:ro" + - "kolla_logs:/var/log/kolla/" run_once: True delegate_to: "{{ groups['neutron-server'][0] }}" when: database_created diff --git a/ansible/roles/neutron/tasks/start.yml b/ansible/roles/neutron/tasks/start.yml index 31b3405b54..48f65f01f9 100644 --- a/ansible/roles/neutron/tasks/start.yml +++ b/ansible/roles/neutron/tasks/start.yml @@ -67,7 +67,7 @@ name: "neutron_server" volumes: - "{{ node_config_directory }}/neutron-server/:{{ container_config_directory }}/:ro" - - "rsyslog_socket:/var/lib/kolla/rsyslog/" + - "kolla_logs:/var/log/kolla/" when: inventory_hostname in groups['neutron-server'] - name: Starting neutron-openvswitch-agent container @@ -81,7 +81,7 @@ - "{{ node_config_directory }}/neutron-openvswitch-agent/:{{ container_config_directory }}/:ro" - "/lib/modules:/lib/modules:ro" - "/run:/run" - - "rsyslog_socket:/var/lib/kolla/rsyslog/" + - "kolla_logs:/var/log/kolla/" when: - ( ( inventory_hostname in groups['compute'] @@ -109,7 +109,7 @@ - "{{ node_config_directory }}/neutron-openvswitch-agent-fake-{{ item }}/:{{ container_config_directory }}/:ro" - "/lib/modules:/lib/modules:ro" - "/run:/run" - - "rsyslog_socket:/var/lib/kolla/rsyslog/" + - "kolla_logs:/var/log/kolla/" with_sequence: start=1 end={{ num_nova_fake_per_node }} when: - inventory_hostname in groups['compute'] @@ -131,7 +131,7 @@ - "{{ node_config_directory }}/neutron-linuxbridge-agent/:{{ container_config_directory }}/:ro" - "/lib/modules:/lib/modules:ro" - "/run:/run" - - "rsyslog_socket:/var/lib/kolla/rsyslog/" + - "kolla_logs:/var/log/kolla/" when: - (inventory_hostname in groups['compute'] or inventory_hostname in groups['neutron-dhcp-agent'] @@ -151,7 +151,7 @@ - "/run/:/run/" - "/run/netns/:/run/netns/:shared" - "neutron_metadata_socket:/var/lib/neutron/kolla/" - - "rsyslog_socket:/var/lib/kolla/rsyslog/" + - "kolla_logs:/var/log/kolla/" when: - inventory_hostname in groups['neutron-dhcp-agent'] @@ -167,7 +167,7 @@ - "/run:/run" - "/run/netns/:/run/netns/:shared" - "neutron_metadata_socket:/var/lib/neutron/kolla/" - - "rsyslog_socket:/var/lib/kolla/rsyslog/" + - "kolla_logs:/var/log/kolla/" when: - inventory_hostname in groups['neutron-l3-agent'] @@ -182,6 +182,6 @@ - "{{ node_config_directory }}/neutron-metadata-agent/:{{ container_config_directory }}/:ro" - "/run/netns/:/run/netns/:shared" - "neutron_metadata_socket:/var/lib/neutron/kolla/" - - "rsyslog_socket:/var/lib/kolla/rsyslog/" + - "kolla_logs:/var/log/kolla/" when: - inventory_hostname in groups['neutron-metadata-agent'] diff --git a/ansible/roles/neutron/templates/neutron.conf.j2 b/ansible/roles/neutron/templates/neutron.conf.j2 index 8db961e8e8..6a0f8a1623 100644 --- a/ansible/roles/neutron/templates/neutron.conf.j2 +++ b/ansible/roles/neutron/templates/neutron.conf.j2 @@ -2,8 +2,11 @@ [DEFAULT] debug = {{ neutron_logging_debug }} -use_syslog = True -syslog_log_facility = LOG_LOCAL0 +log_dir = /var/log/kolla/neutron + +# NOTE(elemoine): set use_stderr to False or the logs will also be sent to +# stderr and collected by Docker +use_stderr = False bind_host = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} bind_port = {{ neutron_server_port }} diff --git a/docker/neutron/neutron-base/Dockerfile.j2 b/docker/neutron/neutron-base/Dockerfile.j2 index cece61ed73..4084544e4b 100644 --- a/docker/neutron/neutron-base/Dockerfile.j2 +++ b/docker/neutron/neutron-base/Dockerfile.j2 @@ -48,17 +48,20 @@ ADD neutron-base-archive /neutron-base-source RUN ln -s neutron-base-source/* neutron \ && useradd --user-group neutron \ && /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt /neutron \ - && mkdir -p /etc/neutron /usr/share/neutron /var/lib/neutron /var/log/neutron /home/neutron \ + && mkdir -p /etc/neutron /usr/share/neutron /var/lib/neutron /home/neutron \ && cp -r /neutron/etc/* /etc/neutron/ \ && cp -r /neutron/etc/neutron/* /etc/neutron/ \ && cp /neutron/etc/api-paste.ini /usr/share/neutron \ && mv /etc/neutron/neutron/ /etc/neutron/plugins/ \ - && chown -R neutron: /etc/neutron /usr/share/neutron /var/lib/neutron /var/log/neutron /home/neutron \ + && chown -R neutron: /etc/neutron /usr/share/neutron /var/lib/neutron /home/neutron \ && sed -i 's|^exec_dirs.*|exec_dirs=/var/lib/kolla/venv/bin,/sbin,/usr/sbin,/bin,/usr/bin,/usr/local/bin,/usr/local/sbin|g' /etc/neutron/rootwrap.conf {% endif %} COPY neutron_sudoers /etc/sudoers.d/neutron_sudoers +COPY extend_start.sh /usr/local/bin/kolla_extend_start + RUN usermod -a -G kolla neutron \ && chmod 750 /etc/sudoers.d \ - && chmod 440 /etc/sudoers.d/neutron_sudoers + && chmod 440 /etc/sudoers.d/neutron_sudoers \ + && chmod 755 /usr/local/bin/kolla_extend_start diff --git a/docker/neutron/neutron-base/extend_start.sh b/docker/neutron/neutron-base/extend_start.sh new file mode 100644 index 0000000000..8c71d1a235 --- /dev/null +++ b/docker/neutron/neutron-base/extend_start.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [[ ! -d "/var/log/kolla/neutron" ]]; then + mkdir -p /var/log/kolla/neutron +fi +if [[ $(stat -c %a /var/log/kolla/neutron) != "755" ]]; then + chmod 755 /var/log/kolla/neutron +fi diff --git a/docker/neutron/neutron-metadata-agent/extend_start.sh b/docker/neutron/neutron-metadata-agent/extend_start.sh index c46f60f555..aed5134a89 100644 --- a/docker/neutron/neutron-metadata-agent/extend_start.sh +++ b/docker/neutron/neutron-metadata-agent/extend_start.sh @@ -4,3 +4,10 @@ if [[ $(stat -c %U:%G /var/lib/neutron/kolla) != "neutron:neutron" ]]; then sudo chown neutron: /var/lib/neutron/kolla fi + +if [[ ! -d "/var/log/kolla/neutron" ]]; then + mkdir -p /var/log/kolla/neutron +fi +if [[ $(stat -c %a /var/log/kolla/neutron) != "755" ]]; then + chmod 755 /var/log/kolla/neutron +fi diff --git a/docker/neutron/neutron-server/extend_start.sh b/docker/neutron/neutron-server/extend_start.sh index dba1e632f2..7247c8de5f 100644 --- a/docker/neutron/neutron-server/extend_start.sh +++ b/docker/neutron/neutron-server/extend_start.sh @@ -1,5 +1,12 @@ #!/bin/bash +if [[ ! -d "/var/log/kolla/neutron" ]]; then + mkdir -p /var/log/kolla/neutron +fi +if [[ $(stat -c %a /var/log/kolla/neutron) != "755" ]]; then + chmod 755 /var/log/kolla/neutron +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