Add option for heat containers to log to stdout/stderr

This adds the option to get the heat containers to log to stdout.
The option is disabled by default.

If enabled, It also adds a sidecar container that reads the apache
access logs.

bp logging-stdout-rsyslog

Depends-On: Iae6a86cb93305cb3307e058cfd31e0fca3b1be8e
Change-Id: Iac79232bc981fff365faa818afde72e38fc176fb
This commit is contained in:
Juan Antonio Osorio Robles 2017-10-25 12:06:48 +00:00 committed by Jiri Stransky
parent 759d10770d
commit 97e3a2fd0d
11 changed files with 274 additions and 38 deletions

View File

@ -60,6 +60,9 @@ resources:
RoleName: {get_param: RoleName} RoleName: {get_param: RoleName}
RoleParameters: {get_param: RoleParameters} RoleParameters: {get_param: RoleParameters}
HeatApiCfnLogging:
type: OS::TripleO::Services::Logging::HeatApiCfn
outputs: outputs:
role_data: role_data:
description: Role data for the Heat API CFN role. description: Role data for the Heat API CFN role.
@ -68,6 +71,7 @@ outputs:
config_settings: config_settings:
map_merge: map_merge:
- get_attr: [HeatBase, role_data, config_settings] - get_attr: [HeatBase, role_data, config_settings]
- get_attr: [HeatApiCfnLogging, config_settings]
- apache::default_vhost: false - apache::default_vhost: false
logging_source: {get_attr: [HeatBase, role_data, logging_source]} logging_source: {get_attr: [HeatBase, role_data, logging_source]}
logging_groups: {get_attr: [HeatBase, role_data, logging_groups]} logging_groups: {get_attr: [HeatBase, role_data, logging_groups]}
@ -93,6 +97,8 @@ outputs:
owner: heat:heat owner: heat:heat
recurse: true recurse: true
docker_config: docker_config:
step_2:
get_attr: [HeatApiCfnLogging, docker_config, step_2]
step_4: step_4:
heat_api_cfn: heat_api_cfn:
image: {get_param: DockerHeatApiCfnImage} image: {get_param: DockerHeatApiCfnImage}
@ -107,11 +113,10 @@ outputs:
volumes: volumes:
list_concat: list_concat:
- {get_attr: [ContainersCommon, volumes]} - {get_attr: [ContainersCommon, volumes]}
- {get_attr: [HeatApiCfnLogging, volumes]}
- -
- /var/lib/kolla/config_files/heat_api_cfn.json:/var/lib/kolla/config_files/config.json:ro - /var/lib/kolla/config_files/heat_api_cfn.json:/var/lib/kolla/config_files/config.json:ro
- /var/lib/config-data/puppet-generated/heat_api_cfn/:/var/lib/kolla/config_files/src:ro - /var/lib/config-data/puppet-generated/heat_api_cfn/:/var/lib/kolla/config_files/src:ro
- /var/log/containers/heat:/var/log/heat
- /var/log/containers/httpd/heat-api-cfn:/var/log/httpd
- -
if: if:
- internal_tls_enabled - internal_tls_enabled
@ -124,14 +129,7 @@ outputs:
- '' - ''
environment: environment:
- KOLLA_CONFIG_STRATEGY=COPY_ALWAYS - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
host_prep_tasks: host_prep_tasks: {get_attr: [HeatApiCfnLogging, host_prep_tasks]}
- name: create persistent logs directory
file:
path: "{{ item }}"
state: directory
with_items:
- /var/log/containers/heat
- /var/log/containers/httpd/heat-api-cfn
upgrade_tasks: upgrade_tasks:
- name: Check if heat_api_cfn is deployed - name: Check if heat_api_cfn is deployed
command: systemctl is-enabled openstack-heat-api-cfn command: systemctl is-enabled openstack-heat-api-cfn

View File

@ -60,6 +60,9 @@ resources:
RoleName: {get_param: RoleName} RoleName: {get_param: RoleName}
RoleParameters: {get_param: RoleParameters} RoleParameters: {get_param: RoleParameters}
HeatApiLogging:
type: OS::TripleO::Services::Logging::HeatApi
outputs: outputs:
role_data: role_data:
description: Role data for the Heat API role. description: Role data for the Heat API role.
@ -68,6 +71,7 @@ outputs:
config_settings: config_settings:
map_merge: map_merge:
- get_attr: [HeatBase, role_data, config_settings] - get_attr: [HeatBase, role_data, config_settings]
- get_attr: [HeatApiLogging, config_settings]
- apache::default_vhost: false - apache::default_vhost: false
step_config: &step_config step_config: &step_config
get_attr: [HeatBase, role_data, step_config] get_attr: [HeatBase, role_data, step_config]
@ -104,6 +108,8 @@ outputs:
owner: heat:heat owner: heat:heat
recurse: true recurse: true
docker_config: docker_config:
step_2:
get_attr: [HeatApiLogging, docker_config, step_2]
step_4: step_4:
heat_api: heat_api:
image: {get_param: DockerHeatApiImage} image: {get_param: DockerHeatApiImage}
@ -118,11 +124,10 @@ outputs:
volumes: volumes:
list_concat: list_concat:
- {get_attr: [ContainersCommon, volumes]} - {get_attr: [ContainersCommon, volumes]}
- {get_attr: [HeatApiLogging, volumes]}
- -
- /var/lib/kolla/config_files/heat_api.json:/var/lib/kolla/config_files/config.json:ro - /var/lib/kolla/config_files/heat_api.json:/var/lib/kolla/config_files/config.json:ro
- /var/lib/config-data/puppet-generated/heat_api/:/var/lib/kolla/config_files/src:ro - /var/lib/config-data/puppet-generated/heat_api/:/var/lib/kolla/config_files/src:ro
- /var/log/containers/heat:/var/log/heat
- /var/log/containers/httpd/heat-api:/var/log/httpd
- -
if: if:
- internal_tls_enabled - internal_tls_enabled
@ -144,21 +149,13 @@ outputs:
volumes: volumes:
list_concat: list_concat:
- {get_attr: [ContainersCommon, volumes]} - {get_attr: [ContainersCommon, volumes]}
- {get_attr: [HeatApiLogging, volumes]}
- -
- /var/lib/kolla/config_files/heat_api_cron.json:/var/lib/kolla/config_files/config.json:ro - /var/lib/kolla/config_files/heat_api_cron.json:/var/lib/kolla/config_files/config.json:ro
- /var/lib/config-data/puppet-generated/heat_api/:/var/lib/kolla/config_files/src:ro - /var/lib/config-data/puppet-generated/heat_api/:/var/lib/kolla/config_files/src:ro
- /var/log/containers/heat:/var/log/heat
- /var/log/containers/httpd/heat-api:/var/log/httpd
environment: environment:
- KOLLA_CONFIG_STRATEGY=COPY_ALWAYS - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
host_prep_tasks: host_prep_tasks: {get_attr: [HeatApiLogging, host_prep_tasks]}
- name: create persistent logs directory
file:
path: "{{ item }}"
state: directory
with_items:
- /var/log/containers/heat
- /var/log/containers/httpd/heat-api
upgrade_tasks: upgrade_tasks:
- name: Check is heat_api is deployed - name: Check is heat_api is deployed
command: systemctl is-enabled openstack-heat-api command: systemctl is-enabled openstack-heat-api

View File

@ -55,6 +55,9 @@ resources:
RoleName: {get_param: RoleName} RoleName: {get_param: RoleName}
RoleParameters: {get_param: RoleParameters} RoleParameters: {get_param: RoleParameters}
HeatEngineLogging:
type: OS::TripleO::Services::Logging::HeatEngine
outputs: outputs:
role_data: role_data:
description: Role data for the Heat Engine role. description: Role data for the Heat Engine role.
@ -80,7 +83,11 @@ outputs:
config_image: {get_param: DockerHeatConfigImage} config_image: {get_param: DockerHeatConfigImage}
kolla_config: kolla_config:
/var/lib/kolla/config_files/heat_engine.json: /var/lib/kolla/config_files/heat_engine.json:
command: /usr/bin/heat-engine --config-file /usr/share/heat/heat-dist.conf --config-file /etc/heat/heat.conf command:
list_join:
- ' '
- - /usr/bin/heat-engine --config-file /usr/share/heat/heat-dist.conf --config-file /etc/heat/heat.conf
- get_attr: [HeatEngineLogging, cmd_extra_args]
config_files: config_files:
- source: "/var/lib/kolla/config_files/src/*" - source: "/var/lib/kolla/config_files/src/*"
dest: "/" dest: "/"
@ -93,15 +100,10 @@ outputs:
docker_config: docker_config:
# db sync runs before permissions set by kolla_config # db sync runs before permissions set by kolla_config
step_2: step_2:
heat_init_log: get_attr: [HeatEngineLogging, docker_config, step_2]
image: &heat_engine_image {get_param: DockerHeatEngineImage}
user: root
volumes:
- /var/log/containers/heat:/var/log/heat
command: ['/bin/bash', '-c', 'chown -R heat:heat /var/log/heat']
step_3: step_3:
heat_engine_db_sync: heat_engine_db_sync:
image: *heat_engine_image image: &heat_engine_image {get_param: DockerHeatEngineImage}
net: host net: host
privileged: false privileged: false
detach: false detach: false
@ -109,10 +111,10 @@ outputs:
volumes: volumes:
list_concat: list_concat:
- {get_attr: [ContainersCommon, volumes]} - {get_attr: [ContainersCommon, volumes]}
- {get_attr: [HeatEngineLogging, volumes]}
- -
- /var/lib/config-data/heat/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro - /var/lib/config-data/heat/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro
- /var/lib/config-data/heat/etc/heat/:/etc/heat/:ro - /var/lib/config-data/heat/etc/heat/:/etc/heat/:ro
- /var/log/containers/heat:/var/log/heat
command: "/usr/bin/bootstrap_host_exec heat_engine su heat -s /bin/bash -c 'heat-manage db_sync'" command: "/usr/bin/bootstrap_host_exec heat_engine su heat -s /bin/bash -c 'heat-manage db_sync'"
step_4: step_4:
heat_engine: heat_engine:
@ -125,17 +127,13 @@ outputs:
volumes: volumes:
list_concat: list_concat:
- {get_attr: [ContainersCommon, volumes]} - {get_attr: [ContainersCommon, volumes]}
- {get_attr: [HeatEngineLogging, volumes]}
- -
- /var/lib/kolla/config_files/heat_engine.json:/var/lib/kolla/config_files/config.json:ro - /var/lib/kolla/config_files/heat_engine.json:/var/lib/kolla/config_files/config.json:ro
- /var/lib/config-data/puppet-generated/heat/:/var/lib/kolla/config_files/src:ro - /var/lib/config-data/puppet-generated/heat/:/var/lib/kolla/config_files/src:ro
- /var/log/containers/heat:/var/log/heat
environment: environment:
- KOLLA_CONFIG_STRATEGY=COPY_ALWAYS - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
host_prep_tasks: host_prep_tasks: {get_attr: [HeatEngineLogging, host_prep_tasks]}
- name: create persistent logs directory
file:
path: /var/log/containers/heat
state: directory
upgrade_tasks: upgrade_tasks:
- name: Stop and disable heat_engine service - name: Stop and disable heat_engine service
tags: step2 tags: step2

View File

@ -0,0 +1,28 @@
heat_template_version: pike
description: >
OpenStack containerized Heat API CFN 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/heat:/var/log/heat
- /var/log/containers/httpd/heat-api-cfn:/var/log/httpd
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/heat
- /var/log/containers/httpd/heat-api-cfn

View File

@ -0,0 +1,28 @@
heat_template_version: pike
description: >
OpenStack containerized Heat API 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/heat:/var/log/heat
- /var/log/containers/httpd/heat-api:/var/log/httpd
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/heat
- /var/log/containers/httpd/heat-api

View File

@ -0,0 +1,39 @@
heat_template_version: pike
description: >
OpenStack containerized Glance API service
parameters:
DockerHeatEngineImage:
description: image
type: string
outputs:
cmd_extra_args:
description: Extra command line arguments for running the service in the container.
value: ''
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:
# Kolla_bootstrap/db_sync runs before permissions set by kolla_config
step_2:
heat_init_log:
image: {get_param: DockerHeatEngineImage}
user: root
volumes:
- /var/log/containers/heat:/var/log/heat
command: ['/bin/bash', '-c', 'chown -R heat:heat /var/log/heat']
volumes:
description: The volumes needed to log to files in the host.
value:
- /var/log/containers/heat:/var/log/heat
host_prep_tasks:
description: Extra ansible tasks needed for logging to files in the host.
value:
- name: create persistent logs directory
file:
path: /var/log/containers/heat
state: directory

View File

@ -0,0 +1,60 @@
heat_template_version: pike
description: >
OpenStack containerized Heat API CFN service
parameters:
DockerHeatApiCfnImage:
description: image
type: string
outputs:
config_settings:
description: Extra hieradata needed to log to stdout.
value:
heat::wsgi::apache_api_cfn::access_log_file: /var/log/httpd/access.log
heat::wsgi::apache_api_cfn::error_log_file: /var/log/httpd/error_log
docker_config:
description: Extra containers needed for logging to stdout or a sidecar container.
value:
step_2:
heat_api_cfn_apache_error_logs:
start_order: 1
image: {get_param: DockerHeatApiCfnImage}
user: root
privileged: false
restart: always
healthcheck:
test: '[ -p /var/log/httpd/error_log ]'
command: ['/bin/bash', '-c', 'mkdir -p /var/log/httpd && rm -f /var/log/httpd/error_log && mkfifo /var/log/httpd/error_log && while true; do cat /var/log/httpd/error_log; done']
volumes:
- HeatApiCfnLogs:/var/log/
heat_api_cfn_apache_access_logs:
start_order: 1
image: {get_param: DockerHeatApiCfnImage}
user: root
privileged: false
restart: always
healthcheck:
test: '[ -p /var/log/httpd/access.log ]'
command: ['/bin/bash', '-c', 'mkdir -p /var/log/httpd && rm -f /var/log/httpd/access.log && mkfifo /var/log/httpd/access.log && while true; do cat /var/log/httpd/access.log; done']
volumes:
- HeatApiCfnLogs:/var/log/
heat_api_cfn_logs:
start_order: 2
image: {get_param: DockerHeatApiCfnImage}
user: heat
privileged: false
restart: always
healthcheck:
test: '[ -p /var/log/heat/heat_api_cfn.log ]'
command: ['/bin/bash', '-c', 'mkdir -p /var/log/heat && rm -f /var/log/heat/heat_api_cfn.log && mkfifo /var/log/heat/heat_api_cfn.log && while true; do cat /var/log/heat/heat_api_cfn.log; done']
volumes:
- HeatApiCfnLogs:/var/log/
volumes:
description: The volumes needed to log to stdout or a sidecar container.
value:
- HeatApiCfnLogs:/var/log/
host_prep_tasks:
description: Extra ansible tasks needed for logging to files in the host.
value: null

View File

@ -0,0 +1,60 @@
heat_template_version: pike
description: >
OpenStack containerized Heat API service
parameters:
DockerHeatApiImage:
description: image
type: string
outputs:
config_settings:
description: Extra hieradata needed to log to stdout.
value:
heat::wsgi::apache_api::access_log_file: /var/log/httpd/access.log
heat::wsgi::apache_api::error_log_file: /var/log/httpd/error_log
docker_config:
description: Extra containers needed for logging to stdout or a sidecar container.
value:
step_2:
heat_api_apache_error_logs:
start_order: 1
image: {get_param: DockerHeatApiImage}
user: root
privileged: false
restart: always
healthcheck:
test: '[ -p /var/log/httpd/error_log ]'
command: ['/bin/bash', '-c', 'mkdir -p /var/log/httpd && rm -f /var/log/httpd/error_log && mkfifo /var/log/httpd/error_log && while true; do cat /var/log/httpd/error_log; done']
volumes:
- HeatApiLogs:/var/log/
heat_api_apache_access_logs:
start_order: 1
image: {get_param: DockerHeatApiImage}
user: root
privileged: false
restart: always
healthcheck:
test: '[ -p /var/log/httpd/access.log ]'
command: ['/bin/bash', '-c', 'mkdir -p /var/log/httpd && rm -f /var/log/httpd/access.log && mkfifo /var/log/httpd/access.log && while true; do cat /var/log/httpd/access.log; done']
volumes:
- HeatApiLogs:/var/log/
heat_api_logs:
start_order: 2
image: {get_param: DockerHeatApiImage}
user: heat
privileged: false
restart: always
healthcheck:
test: '[ -p /var/log/heat/heat_api.log ]'
command: ['/bin/bash', '-c', 'mkdir -p /var/log/heat && rm -f /var/log/heat/heat_api.log && mkfifo /var/log/heat/heat_api.log && while true; do cat /var/log/heat/heat_api.log; done']
volumes:
- HeatApiLogs:/var/log/
volumes:
description: The volumes needed to log to stdout or a sidecar container.
value:
- HeatApiLogs:/var/log/
host_prep_tasks:
description: Extra ansible tasks needed for logging to files in the host.
value: null

View File

@ -0,0 +1,22 @@
heat_template_version: pike
description: >
OpenStack containerized Glance API service
outputs:
cmd_extra_args:
description: Extra command line arguments for running the service in the container.
value: "--log-dir= --log-file="
config_settings:
description: Extra hieradata needed to log to stdout.
value: null
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

View File

@ -1,6 +1,9 @@
resource_registry: resource_registry:
OS::TripleO::Services::Logging::GlanceApi: ../docker/services/logging/stdout/glance-api.yaml OS::TripleO::Services::Logging::GlanceApi: ../docker/services/logging/stdout/glance-api.yaml
OS::TripleO::Services::Logging::HeatApi: ../docker/services/logging/stdout/heat-api.yaml
OS::TripleO::Services::Logging::HeatApiCfn: ../docker/services/logging/stdout/heat-api-cfn.yaml
OS::TripleO::Services::Logging::HeatEngine: ../docker/services/logging/stdout/heat-engine.yaml
OS::TripleO::Services::Logging::Keystone: ../docker/services/logging/stdout/keystone.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::NeutronApi: ../docker/services/logging/stdout/neutron-common.yaml
OS::TripleO::Services::Logging::NeutronCommon: ../docker/services/logging/stdout/neutron-common.yaml OS::TripleO::Services::Logging::NeutronCommon: ../docker/services/logging/stdout/neutron-common.yaml

View File

@ -299,13 +299,16 @@ resource_registry:
# Logging # Logging
OS::TripleO::Services::Logging::GlanceApi: docker/services/logging/files/glance-api.yaml OS::TripleO::Services::Logging::GlanceApi: docker/services/logging/files/glance-api.yaml
OS::TripleO::Services::Logging::HeatApi: docker/services/logging/files/heat-api.yaml
OS::TripleO::Services::Logging::HeatApiCfn: docker/services/logging/files/heat-api-cfn.yaml
OS::TripleO::Services::Logging::HeatEngine: docker/services/logging/files/heat-engine.yaml
OS::TripleO::Services::Logging::Keystone: docker/services/logging/files/keystone.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::NeutronApi: docker/services/logging/files/neutron-api.yaml
OS::TripleO::Services::Logging::NeutronCommon: docker/services/logging/files/neutron-common.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::NovaApi: docker/services/logging/files/nova-api.yaml
OS::TripleO::Services::Logging::NovaCommon: docker/services/logging/files/nova-common.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
OS::TripleO::Services::Logging::NovaLibvirt: OS::Heat::None OS::TripleO::Services::Logging::NovaLibvirt: OS::Heat::None
OS::TripleO::Services::Logging::NovaPlacement: docker/services/logging/files/nova-placement.yaml
parameter_defaults: parameter_defaults:
EnablePackageInstall: false EnablePackageInstall: false