New parameter: ContainerLogStdoutPath

This is used in order to point where podman must push its logs.
Two scripts are using it:
- docker-puppet.py
- paunch (near future - see https://review.openstack.org/#/c/635438/)

This will allow to get the stdout for all containers, even when they
are removed before we can actually run "podman logs container_name".

Related-Bug: #1814897
Change-Id: Idc220047d56ce0eb41ac43903877177c4f7b75c2
This commit is contained in:
Cédric Jeanneret 2019-02-08 09:55:07 +01:00
parent afe1cb5581
commit 3d07ad4326
4 changed files with 35 additions and 3 deletions

View File

@ -36,9 +36,9 @@
selevel: s0 selevel: s0
tags: tags:
- host_config - host_config
- name: Create /var/log/containers/stdouts directory - name: Create ContainerLogStdoutPath directory
file: file:
path: /var/log/containers/stdouts path: "{{ container_log_stdout_path }}"
state: directory state: directory
selevel: s0 selevel: s0
tags: tags:
@ -414,6 +414,7 @@
CHECK_MODE: '{{ ansible_check_mode | ternary(1, 0) }}' CHECK_MODE: '{{ ansible_check_mode | ternary(1, 0) }}'
STARTUP_CONFIG_PATTERN: '/var/lib/tripleo-config/{{ ansible_check_mode | ternary("check-mode/", "") }}docker-container-startup-config-step_*.json' STARTUP_CONFIG_PATTERN: '/var/lib/tripleo-config/{{ ansible_check_mode | ternary("check-mode/", "") }}docker-container-startup-config-step_*.json'
MOUNT_HOST_PUPPET: '{{docker_puppet_mount_host_puppet | default(true)}}' MOUNT_HOST_PUPPET: '{{docker_puppet_mount_host_puppet | default(true)}}'
CONTAINER_LOG_STDOUT_PATH: "{{ container_log_stdout_path }}"
when: step == "1" when: step == "1"
changed_when: false changed_when: false
check_mode: no check_mode: no
@ -465,6 +466,9 @@
# Note docker-puppet.py generates the hashed-*.json file, which is a copy of # Note docker-puppet.py generates the hashed-*.json file, which is a copy of
# the *step_n.json with a hash of the generated external config added # the *step_n.json with a hash of the generated external config added
# This acts as a salt to enable restarting the container if config changes # This acts as a salt to enable restarting the container if config changes
# TODO(cjeanner): add --container-log-path {{ container_log_stdout_path }} once
# we have new paunch version related to
# https://review.openstack.org/#/c/635438/
- name: Start containers for step {{ step }} - name: Start containers for step {{ step }}
command: >- command: >-
paunch {% if enable_debug|bool %}--debug{% else %}-v{% endif %} apply paunch {% if enable_debug|bool %}--debug{% else %}-v{% endif %} apply

View File

@ -90,6 +90,10 @@ parameters:
ssh_known_hosts_hostnames: ssh_known_hosts_hostnames:
description: Mapping of hostname to ssh known hosts entry description: Mapping of hostname to ssh known hosts entry
type: json type: json
ContainerLogStdoutPath:
type: string
description: Absolute path for container stdout output (Podman only)
default: /var/log/containers/stdouts
{% for role in enabled_roles %} {% for role in enabled_roles %}
{{role.name}}Count: {{role.name}}Count:
description: Number of {{role.name}} nodes to deploy description: Number of {{role.name}} nodes to deploy
@ -235,6 +239,7 @@ outputs:
ENABLE_DEBUG: {get_param: ConfigDebug} ENABLE_DEBUG: {get_param: ConfigDebug}
ENABLE_PUPPET: {get_param: EnablePuppet} ENABLE_PUPPET: {get_param: EnablePuppet}
CONTAINER_CLI: {get_param: ContainerCli} CONTAINER_CLI: {get_param: ContainerCli}
CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath}
DOCKER_PUPPET_DEBUG: {get_param: DockerPuppetDebug} DOCKER_PUPPET_DEBUG: {get_param: DockerPuppetDebug}
DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount} DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount}
DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet} DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet}
@ -281,6 +286,7 @@ outputs:
enable_debug: ENABLE_DEBUG enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI container_cli: CONTAINER_CLI
container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH
docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
@ -320,6 +326,7 @@ outputs:
enable_debug: ENABLE_DEBUG enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI container_cli: CONTAINER_CLI
container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH
docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
@ -346,6 +353,7 @@ outputs:
enable_debug: ENABLE_DEBUG enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI container_cli: CONTAINER_CLI
container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH
docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
@ -370,6 +378,7 @@ outputs:
enable_debug: ENABLE_DEBUG enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI container_cli: CONTAINER_CLI
container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH
docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
@ -394,6 +403,7 @@ outputs:
enable_debug: ENABLE_DEBUG enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI container_cli: CONTAINER_CLI
container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH
docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
@ -435,6 +445,7 @@ outputs:
enable_debug: ENABLE_DEBUG enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI container_cli: CONTAINER_CLI
container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH
docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
@ -457,6 +468,7 @@ outputs:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts} DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts} DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
CONTAINER_CLI: {get_param: ContainerCli} CONTAINER_CLI: {get_param: ContainerCli}
CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath}
DEPLOY_IDENTIFIER: {get_param: DeployIdentifier} DEPLOY_IDENTIFIER: {get_param: DeployIdentifier}
BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]} BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]}
ENABLE_DEBUG: {get_param: ConfigDebug} ENABLE_DEBUG: {get_param: ConfigDebug}
@ -488,6 +500,7 @@ outputs:
enable_debug: ENABLE_DEBUG enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI container_cli: CONTAINER_CLI
container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH
docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
@ -617,6 +630,7 @@ outputs:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts} DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts} DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
CONTAINER_CLI: {get_param: ContainerCli} CONTAINER_CLI: {get_param: ContainerCli}
CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath}
DEPLOY_IDENTIFIER: {get_param: DeployIdentifier} DEPLOY_IDENTIFIER: {get_param: DeployIdentifier}
BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]} BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]}
ENABLE_DEBUG: {get_param: ConfigDebug} ENABLE_DEBUG: {get_param: ConfigDebug}
@ -636,6 +650,7 @@ outputs:
enable_debug: ENABLE_DEBUG enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI container_cli: CONTAINER_CLI
container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH
docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
@ -653,6 +668,7 @@ outputs:
DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts} DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts}
DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts} DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts}
CONTAINER_CLI: {get_param: ContainerCli} CONTAINER_CLI: {get_param: ContainerCli}
CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath}
DEPLOY_IDENTIFIER: {get_param: DeployIdentifier} DEPLOY_IDENTIFIER: {get_param: DeployIdentifier}
BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]} BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]}
ENABLE_DEBUG: {get_param: ConfigDebug} ENABLE_DEBUG: {get_param: ConfigDebug}
@ -672,6 +688,7 @@ outputs:
enable_debug: ENABLE_DEBUG enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI container_cli: CONTAINER_CLI
container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH
docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
@ -691,6 +708,7 @@ outputs:
DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount} DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount}
DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet} DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet}
CONTAINER_CLI: {get_param: ContainerCli} CONTAINER_CLI: {get_param: ContainerCli}
CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath}
template: | template: |
- hosts: DEPLOY_SOURCE_HOST - hosts: DEPLOY_SOURCE_HOST
name: Gather facts from undercloud name: Gather facts from undercloud
@ -724,6 +742,7 @@ outputs:
enable_debug: ENABLE_DEBUG enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI container_cli: CONTAINER_CLI
container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH
docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET
@ -749,6 +768,7 @@ outputs:
enable_debug: ENABLE_DEBUG enable_debug: ENABLE_DEBUG
enable_puppet: ENABLE_PUPPET enable_puppet: ENABLE_PUPPET
container_cli: CONTAINER_CLI container_cli: CONTAINER_CLI
container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH
docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_debug: DOCKER_PUPPET_DEBUG
docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT
docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET

View File

@ -33,6 +33,8 @@ from paunch import runner as containers_runner
logger = None logger = None
sh_script = '/var/lib/docker-puppet/docker-puppet.sh' sh_script = '/var/lib/docker-puppet/docker-puppet.sh'
container_cli = os.environ.get('CONTAINER_CLI', 'docker') container_cli = os.environ.get('CONTAINER_CLI', 'docker')
container_log_stdout_path = os.environ.get('CONTAINER_LOG_STDOUT_PATH',
'/var/log/containers/stdouts')
cli_cmd = '/usr/bin/' + container_cli cli_cmd = '/usr/bin/' + container_cli
@ -425,8 +427,9 @@ def mp_puppet_config(*args):
common_dcmd.push('--privileged') common_dcmd.push('--privileged')
if container_cli == 'podman': if container_cli == 'podman':
log_path = os.path.join(container_log_stdout_path, uname)
logging = ['--log-opt', logging = ['--log-opt',
'path=/var/log/containers/stdouts/%s.log' % uname] 'path=%s.log' % log_path]
common_dcmd.extend(logging) common_dcmd.extend(logging)

View File

@ -0,0 +1,5 @@
---
features:
- Introduce new parameter, ContainerLogStdoutPath. Must be an absolute path
to a directory where podman will output all containers stdout. The
existence of the directory is ensured directly as a host_prep_task.