From e0441af380d6f814035ec6e9139831d5ea7a10bf Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Robles Date: Mon, 9 Oct 2017 10:01:07 +0000 Subject: [PATCH] Add option for Neutron containers to log to stdout/stderr This adds the option to get the neutron containers to log to stdout. The option is disabled by default. bp logging-stdout-rsyslog Change-Id: I0f9d201d93da702b702e7ecf4b43a6d705389846 --- .../services/logging/files/neutron-api.yaml | 40 +++++++++++++++++++ .../logging/files/neutron-common.yaml | 26 ++++++++++++ .../logging/stdout/neutron-common.yaml | 20 ++++++++++ docker/services/neutron-api.yaml | 31 +++++--------- docker/services/neutron-dhcp.yaml | 20 +++++----- docker/services/neutron-l3.yaml | 24 ++++++----- docker/services/neutron-metadata.yaml | 24 ++++++----- docker/services/neutron-ovs-agent.yaml | 16 ++++---- docker/services/neutron-sriov-agent.yaml | 16 ++++---- environments/stdout-logging.yaml | 2 + overcloud-resource-registry-puppet.j2.yaml | 2 + 11 files changed, 156 insertions(+), 65 deletions(-) create mode 100644 docker/services/logging/files/neutron-api.yaml create mode 100644 docker/services/logging/files/neutron-common.yaml create mode 100644 docker/services/logging/stdout/neutron-common.yaml diff --git a/docker/services/logging/files/neutron-api.yaml b/docker/services/logging/files/neutron-api.yaml new file mode 100644 index 0000000000..d8c64e7cd4 --- /dev/null +++ b/docker/services/logging/files/neutron-api.yaml @@ -0,0 +1,40 @@ +heat_template_version: pike + +description: > + OpenStack containerized Neutron API service + +parameters: + DockerNeutronApiImage: + description: image + type: string + +outputs: + config_settings: + description: Extra hieradata needed to log to files in the host. + value: null + volumes: + description: extra volumes + value: &neutron_api_volumes + - /var/log/containers/neutron:/var/log/neutron + - /var/log/containers/httpd/neutron-api:/var/log/httpd + docker_config: + description: Extra containers needed for logging to files in the host. + value: + # db sync runs before permissions set by kolla_config + step_2: + neutron_init_logs: + image: {get_param: DockerNeutronApiImage} + privileged: false + user: root + volumes: *neutron_api_volumes + command: ['/bin/bash', '-c', 'chown -R neutron:neutron /var/log/neutron'] + host_prep_tasks: + description: Extra ansible tasks needed for logging to files in the host. + value: + - name: create persistent logs directory + file: + path: "{{ item }}" + state: directory + with_items: + - /var/log/containers/neutron + - /var/log/containers/httpd/neutron-api diff --git a/docker/services/logging/files/neutron-common.yaml b/docker/services/logging/files/neutron-common.yaml new file mode 100644 index 0000000000..95a9828074 --- /dev/null +++ b/docker/services/logging/files/neutron-common.yaml @@ -0,0 +1,26 @@ +heat_template_version: pike + +description: > + OpenStack containerized Neutron service + +outputs: + config_settings: + description: Extra hieradata needed to log to files in the host. + value: null + docker_config: + description: Extra containers needed for logging to files in the host. + value: + step_2: {} + volumes: + description: The volumes needed to log to files in the host. + value: + - /var/log/containers/neutron:/var/log/neutron + host_prep_tasks: + description: Extra ansible tasks needed for logging to files in the host. + value: + - name: create persistent logs directory + file: + path: "{{ item }}" + state: directory + with_items: + - /var/log/containers/neutron diff --git a/docker/services/logging/stdout/neutron-common.yaml b/docker/services/logging/stdout/neutron-common.yaml new file mode 100644 index 0000000000..f3177c44e5 --- /dev/null +++ b/docker/services/logging/stdout/neutron-common.yaml @@ -0,0 +1,20 @@ +heat_template_version: pike + +description: > + OpenStack containerized Neutron API service + +outputs: + config_settings: + description: Extra hieradata needed to log to stdout. + value: + neutron::logging::log_dir: '' + docker_config: + description: Extra containers needed for logging to stdout or a sidecar container. + value: + step_2: {} + volumes: + description: The volumes needed to log to stdout or a sidecar container. + value: null + host_prep_tasks: + description: Extra ansible tasks needed for logging to files in the host. + value: null diff --git a/docker/services/neutron-api.yaml b/docker/services/neutron-api.yaml index 34d70ff03a..534e6574ae 100644 --- a/docker/services/neutron-api.yaml +++ b/docker/services/neutron-api.yaml @@ -66,6 +66,9 @@ resources: RoleName: {get_param: RoleName} RoleParameters: {get_param: RoleParameters} + NeutronLogging: + type: OS::TripleO::Services::Logging::NeutronApi + outputs: role_data: description: Role data for the Neutron API role. @@ -76,6 +79,7 @@ outputs: config_settings: map_merge: - get_attr: [NeutronBase, role_data, config_settings] + - get_attr: [NeutronLogging, config_settings] step_config: &step_config list_join: - "\n" @@ -108,19 +112,11 @@ outputs: merge: true preserve_properties: true docker_config: - # db sync runs before permissions set by kolla_config step_2: - neutron_init_logs: - image: &neutron_api_image {get_param: DockerNeutronApiImage} - privileged: false - user: root - volumes: - - /var/log/containers/neutron:/var/log/neutron - - /var/log/containers/httpd/neutron-api:/var/log/httpd - command: ['/bin/bash', '-c', 'chown -R neutron:neutron /var/log/neutron'] + get_attr: [NeutronLogging, docker_config, step_2] step_3: neutron_db_sync: - image: *neutron_api_image + image: &neutron_api_image {get_param: DockerNeutronApiImage} net: host privileged: false detach: false @@ -128,12 +124,11 @@ outputs: volumes: list_concat: - {get_attr: [ContainersCommon, volumes]} + - {get_attr: [NeutronLogging, volumes]} - - /var/lib/config-data/neutron/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro - /var/lib/config-data/neutron/etc/neutron:/etc/neutron:ro - /var/lib/config-data/neutron/usr/share/neutron:/usr/share/neutron:ro - - /var/log/containers/neutron:/var/log/neutron - - /var/log/containers/httpd/neutron-api:/var/log/httpd command: ['/usr/bin/bootstrap_host_exec', 'neutron_api', 'neutron-db-manage', 'upgrade', 'heads'] # FIXME: we should make config file permissions right # and run as neutron user @@ -148,11 +143,10 @@ outputs: volumes: list_concat: - {get_attr: [ContainersCommon, volumes]} + - {get_attr: [NeutronLogging, volumes]} - - /var/lib/kolla/config_files/neutron_api.json:/var/lib/kolla/config_files/config.json:ro - /var/lib/config-data/puppet-generated/neutron/:/var/lib/kolla/config_files/src:ro - - /var/log/containers/neutron:/var/log/neutron - - /var/log/containers/httpd/neutron-api:/var/log/httpd environment: - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS - if: @@ -173,14 +167,7 @@ outputs: environment: - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS - {} - host_prep_tasks: - - name: create persistent logs directory - file: - path: "{{ item }}" - state: directory - with_items: - - /var/log/containers/neutron - - /var/log/containers/httpd/neutron-api + host_prep_tasks: {get_attr: [NeutronLogging, host_prep_tasks]} upgrade_tasks: - name: Check if neutron_server is deployed command: systemctl is-enabled neutron-server diff --git a/docker/services/neutron-dhcp.yaml b/docker/services/neutron-dhcp.yaml index 15dea43eb9..e5973d4d07 100644 --- a/docker/services/neutron-dhcp.yaml +++ b/docker/services/neutron-dhcp.yaml @@ -52,6 +52,9 @@ resources: RoleName: {get_param: RoleName} RoleParameters: {get_param: RoleParameters} + NeutronLogging: + type: OS::TripleO::Services::Logging::NeutronCommon + outputs: role_data: description: Role data for the Neutron DHCP role. @@ -60,6 +63,7 @@ outputs: config_settings: map_merge: - get_attr: [NeutronBase, role_data, config_settings] + - get_attr: [NeutronLogging, config_settings] logging_source: {get_attr: [NeutronBase, role_data, logging_source]} logging_groups: {get_attr: [NeutronBase, role_data, logging_groups]} step_config: &step_config @@ -97,24 +101,22 @@ outputs: volumes: list_concat: - {get_attr: [ContainersCommon, volumes]} + - {get_attr: [NeutronLogging, volumes]} - - /var/lib/kolla/config_files/neutron_dhcp.json:/var/lib/kolla/config_files/config.json:ro - /var/lib/config-data/puppet-generated/neutron/:/var/lib/kolla/config_files/src:ro - /lib/modules:/lib/modules:ro - /run/:/run - /var/lib/neutron:/var/lib/neutron - - /var/log/containers/neutron:/var/log/neutron environment: - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS host_prep_tasks: - - name: create /var/lib/neutron - file: - path: /var/lib/neutron - state: directory - - name: create persistent logs directory - file: - path: /var/log/containers/neutron - state: directory + list_concat: + - {get_attr: [NeutronLogging, host_prep_tasks]} + - - name: create /var/lib/neutron + file: + path: /var/lib/neutron + state: directory upgrade_tasks: - name: Check if neutron_dhcp_agent is deployed command: systemctl is-enabled neutron-dhcp-agent diff --git a/docker/services/neutron-l3.yaml b/docker/services/neutron-l3.yaml index 09232c2682..e3d64d29aa 100644 --- a/docker/services/neutron-l3.yaml +++ b/docker/services/neutron-l3.yaml @@ -52,12 +52,18 @@ resources: RoleName: {get_param: RoleName} RoleParameters: {get_param: RoleParameters} + NeutronLogging: + type: OS::TripleO::Services::Logging::NeutronCommon + outputs: role_data: description: Role data for Neutron L3 agent value: service_name: {get_attr: [NeutronL3Base, role_data, service_name]} - config_settings: {get_attr: [NeutronL3Base, role_data, config_settings]} + config_settings: + map_merge: + - get_attr: [NeutronL3Base, role_data, config_settings] + - get_attr: [NeutronLogging, config_settings] logging_source: {get_attr: [NeutronL3Base, role_data, logging_source]} logging_groups: {get_attr: [NeutronL3Base, role_data, logging_groups]} step_config: &step_config @@ -93,24 +99,22 @@ outputs: volumes: list_concat: - {get_attr: [ContainersCommon, volumes]} + - {get_attr: [NeutronLogging, volumes]} - - /var/lib/kolla/config_files/neutron_l3_agent.json:/var/lib/kolla/config_files/config.json:ro - /var/lib/config-data/puppet-generated/neutron/:/var/lib/kolla/config_files/src:ro - /lib/modules:/lib/modules:ro - /run:/run - /var/lib/neutron:/var/lib/neutron - - /var/log/containers/neutron:/var/log/neutron environment: - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS host_prep_tasks: - - name: create /var/lib/neutron - file: - path: /var/lib/neutron - state: directory - - name: create persistent logs directory - file: - path: /var/log/containers/neutron - state: directory + list_concat: + - {get_attr: [NeutronLogging, host_prep_tasks]} + - - name: create /var/lib/neutron + file: + path: /var/lib/neutron + state: directory upgrade_tasks: - name: Stop and disable neutron_l3 service tags: step2 diff --git a/docker/services/neutron-metadata.yaml b/docker/services/neutron-metadata.yaml index 9fe839e9dd..de9db6c747 100644 --- a/docker/services/neutron-metadata.yaml +++ b/docker/services/neutron-metadata.yaml @@ -52,12 +52,18 @@ resources: RoleName: {get_param: RoleName} RoleParameters: {get_param: RoleParameters} + NeutronLogging: + type: OS::TripleO::Services::Logging::NeutronCommon + outputs: role_data: description: Role data for Neutron Metadata agent value: service_name: {get_attr: [NeutronMetadataBase, role_data, service_name]} - config_settings: {get_attr: [NeutronMetadataBase, role_data, config_settings]} + config_settings: + map_merge: + - get_attr: [NeutronMetadataBase, role_data, config_settings] + - get_attr: [NeutronLogging, config_settings] logging_source: {get_attr: [NeutronMetadataBase, role_data, logging_source]} logging_groups: {get_attr: [NeutronMetadataBase, role_data, logging_groups]} step_config: &step_config @@ -93,24 +99,22 @@ outputs: volumes: list_concat: - {get_attr: [ContainersCommon, volumes]} + - {get_attr: [NeutronLogging, volumes]} - - /var/lib/kolla/config_files/neutron_metadata_agent.json:/var/lib/kolla/config_files/config.json:ro - /var/lib/config-data/puppet-generated/neutron/:/var/lib/kolla/config_files/src:ro - /lib/modules:/lib/modules:ro - /run:/run - /var/lib/neutron:/var/lib/neutron - - /var/log/containers/neutron:/var/log/neutron environment: - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS host_prep_tasks: - - name: create /var/lib/neutron - file: - path: /var/lib/neutron - state: directory - - name: create persistent logs directory - file: - path: /var/log/containers/neutron - state: directory + list_concat: + - {get_attr: [NeutronLogging, host_prep_tasks]} + - - name: create /var/lib/neutron + file: + path: /var/lib/neutron + state: directory upgrade_tasks: - name: Check if neutron_metadata_agent is deployed command: systemctl is-enabled neutron-metadata-agent diff --git a/docker/services/neutron-ovs-agent.yaml b/docker/services/neutron-ovs-agent.yaml index e6faf34d19..0ce3189987 100644 --- a/docker/services/neutron-ovs-agent.yaml +++ b/docker/services/neutron-ovs-agent.yaml @@ -56,12 +56,18 @@ resources: RoleName: {get_param: RoleName} RoleParameters: {get_param: RoleParameters} + NeutronLogging: + type: OS::TripleO::Services::Logging::NeutronCommon + outputs: role_data: description: Role data for Neutron openvswitch service value: service_name: {get_attr: [NeutronOvsAgentBase, role_data, service_name]} - config_settings: {get_attr: [NeutronOvsAgentBase, role_data, config_settings]} + config_settings: + map_merge: + - get_attr: [NeutronOvsAgentBase, role_data, config_settings] + - get_attr: [NeutronLogging, config_settings] logging_source: {get_attr: [NeutronOvsAgentBase, role_data, logging_source]} logging_groups: {get_attr: [NeutronOvsAgentBase, role_data, logging_groups]} step_config: &step_config @@ -125,19 +131,15 @@ outputs: volumes: list_concat: - {get_attr: [ContainersCommon, volumes]} + - {get_attr: [NeutronLogging, volumes]} - - /var/lib/kolla/config_files/neutron_ovs_agent.json:/var/lib/kolla/config_files/config.json:ro - /var/lib/config-data/puppet-generated/neutron/:/var/lib/kolla/config_files/src:ro - /lib/modules:/lib/modules:ro - /run:/run - - /var/log/containers/neutron:/var/log/neutron environment: - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS - host_prep_tasks: - - name: create persistent logs directory - file: - path: /var/log/containers/neutron - state: directory + host_prep_tasks: {get_attr: [NeutronLogging, host_prep_tasks]} upgrade_tasks: - name: Stop and disable neutron_ovs_agent service tags: step2 diff --git a/docker/services/neutron-sriov-agent.yaml b/docker/services/neutron-sriov-agent.yaml index a9914987c8..6f3619c654 100644 --- a/docker/services/neutron-sriov-agent.yaml +++ b/docker/services/neutron-sriov-agent.yaml @@ -52,12 +52,18 @@ resources: RoleName: {get_param: RoleName} RoleParameters: {get_param: RoleParameters} + NeutronLogging: + type: OS::TripleO::Services::Logging::NeutronCommon + outputs: role_data: description: Role data for Neutron sriov service value: service_name: {get_attr: [NeutronSriovAgentBase, role_data, service_name]} - config_settings: {get_attr: [NeutronSriovAgentBase, role_data, config_settings]} + config_settings: + map_merge: + - get_attr: [NeutronSriovAgentBase, role_data, config_settings] + - get_attr: [NeutronLogging, config_settings] step_config: &step_config get_attr: [NeutronSriovAgentBase, role_data, step_config] puppet_config: @@ -88,20 +94,16 @@ outputs: volumes: list_concat: - {get_attr: [ContainersCommon, volumes]} + - {get_attr: [NeutronLogging, volumes]} - - /var/lib/kolla/config_files/neutron_sriov_agent.json:/var/lib/kolla/config_files/config.json:ro - /var/lib/config-data/puppet-generated/neutron/:/var/lib/kolla/config_files/src:ro - /lib/modules:/lib/modules:ro - /run:/run - - /var/log/containers/neutron:/var/log/neutron - /sys/class/net:/sys/class/net:rw environment: - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS - host_prep_tasks: - - name: create persistent logs directory - file: - path: /var/log/containers/neutron - state: directory + host_prep_tasks: {get_attr: [NeutronLogging, host_prep_tasks]} upgrade_tasks: - name: Stop and disable neutron_sriov_agent service tags: step2 diff --git a/environments/stdout-logging.yaml b/environments/stdout-logging.yaml index c00155eead..2fe30cb9a0 100644 --- a/environments/stdout-logging.yaml +++ b/environments/stdout-logging.yaml @@ -2,6 +2,8 @@ resource_registry: OS::TripleO::Services::Logging::GlanceApi: ../docker/services/logging/stdout/glance-api.yaml OS::TripleO::Services::Logging::Keystone: ../docker/services/logging/stdout/keystone.yaml + OS::TripleO::Services::Logging::NeutronApi: ../docker/services/logging/stdout/neutron-common.yaml + OS::TripleO::Services::Logging::NeutronCommon: ../docker/services/logging/stdout/neutron-common.yaml OS::TripleO::Services::Logging::NovaApi: ../docker/services/logging/stdout/nova-api.yaml OS::TripleO::Services::Logging::NovaCommon: ../docker/services/logging/stdout/nova-common.yaml OS::TripleO::Services::Logging::NovaPlacement: ../docker/services/logging/stdout/nova-placement.yaml diff --git a/overcloud-resource-registry-puppet.j2.yaml b/overcloud-resource-registry-puppet.j2.yaml index 179b5c914a..fd78845ceb 100644 --- a/overcloud-resource-registry-puppet.j2.yaml +++ b/overcloud-resource-registry-puppet.j2.yaml @@ -303,6 +303,8 @@ resource_registry: # Logging OS::TripleO::Services::Logging::GlanceApi: docker/services/logging/files/glance-api.yaml OS::TripleO::Services::Logging::Keystone: docker/services/logging/files/keystone.yaml + OS::TripleO::Services::Logging::NeutronApi: docker/services/logging/files/neutron-api.yaml + OS::TripleO::Services::Logging::NeutronCommon: docker/services/logging/files/neutron-common.yaml OS::TripleO::Services::Logging::NovaApi: docker/services/logging/files/nova-api.yaml OS::TripleO::Services::Logging::NovaCommon: docker/services/logging/files/nova-common.yaml OS::TripleO::Services::Logging::NovaPlacement: docker/services/logging/files/nova-placement.yaml