From 3d07ad43264a8c3ba899a5d341ffd9ef897d217c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Jeanneret?= Date: Fri, 8 Feb 2019 09:55:07 +0100 Subject: [PATCH] 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 --- common/deploy-steps-tasks.yaml | 8 ++++++-- common/deploy-steps.j2 | 20 +++++++++++++++++++ docker/docker-puppet.py | 5 ++++- ...ntainerLogStdoutPath-20cbce05a1710d8a.yaml | 5 +++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/ContainerLogStdoutPath-20cbce05a1710d8a.yaml diff --git a/common/deploy-steps-tasks.yaml b/common/deploy-steps-tasks.yaml index 9b75b1e05f..2960fa6d80 100644 --- a/common/deploy-steps-tasks.yaml +++ b/common/deploy-steps-tasks.yaml @@ -36,9 +36,9 @@ selevel: s0 tags: - host_config - - name: Create /var/log/containers/stdouts directory + - name: Create ContainerLogStdoutPath directory file: - path: /var/log/containers/stdouts + path: "{{ container_log_stdout_path }}" state: directory selevel: s0 tags: @@ -414,6 +414,7 @@ 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' MOUNT_HOST_PUPPET: '{{docker_puppet_mount_host_puppet | default(true)}}' + CONTAINER_LOG_STDOUT_PATH: "{{ container_log_stdout_path }}" when: step == "1" changed_when: false check_mode: no @@ -465,6 +466,9 @@ # 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 # 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 }} command: >- paunch {% if enable_debug|bool %}--debug{% else %}-v{% endif %} apply diff --git a/common/deploy-steps.j2 b/common/deploy-steps.j2 index 079f5eb22a..74c6d05e61 100644 --- a/common/deploy-steps.j2 +++ b/common/deploy-steps.j2 @@ -90,6 +90,10 @@ parameters: ssh_known_hosts_hostnames: description: Mapping of hostname to ssh known hosts entry type: json + ContainerLogStdoutPath: + type: string + description: Absolute path for container stdout output (Podman only) + default: /var/log/containers/stdouts {% for role in enabled_roles %} {{role.name}}Count: description: Number of {{role.name}} nodes to deploy @@ -235,6 +239,7 @@ outputs: ENABLE_DEBUG: {get_param: ConfigDebug} ENABLE_PUPPET: {get_param: EnablePuppet} CONTAINER_CLI: {get_param: ContainerCli} + CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath} DOCKER_PUPPET_DEBUG: {get_param: DockerPuppetDebug} DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount} DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet} @@ -281,6 +286,7 @@ outputs: enable_debug: ENABLE_DEBUG enable_puppet: ENABLE_PUPPET container_cli: CONTAINER_CLI + container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET @@ -320,6 +326,7 @@ outputs: enable_debug: ENABLE_DEBUG enable_puppet: ENABLE_PUPPET container_cli: CONTAINER_CLI + container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET @@ -346,6 +353,7 @@ outputs: enable_debug: ENABLE_DEBUG enable_puppet: ENABLE_PUPPET container_cli: CONTAINER_CLI + container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET @@ -370,6 +378,7 @@ outputs: enable_debug: ENABLE_DEBUG enable_puppet: ENABLE_PUPPET container_cli: CONTAINER_CLI + container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET @@ -394,6 +403,7 @@ outputs: enable_debug: ENABLE_DEBUG enable_puppet: ENABLE_PUPPET container_cli: CONTAINER_CLI + container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET @@ -435,6 +445,7 @@ outputs: enable_debug: ENABLE_DEBUG enable_puppet: ENABLE_PUPPET container_cli: CONTAINER_CLI + container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET @@ -457,6 +468,7 @@ outputs: DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts} DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts} CONTAINER_CLI: {get_param: ContainerCli} + CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath} DEPLOY_IDENTIFIER: {get_param: DeployIdentifier} BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]} ENABLE_DEBUG: {get_param: ConfigDebug} @@ -488,6 +500,7 @@ outputs: enable_debug: ENABLE_DEBUG enable_puppet: ENABLE_PUPPET container_cli: CONTAINER_CLI + container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET @@ -617,6 +630,7 @@ outputs: DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts} DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts} CONTAINER_CLI: {get_param: ContainerCli} + CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath} DEPLOY_IDENTIFIER: {get_param: DeployIdentifier} BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]} ENABLE_DEBUG: {get_param: ConfigDebug} @@ -636,6 +650,7 @@ outputs: enable_debug: ENABLE_DEBUG enable_puppet: ENABLE_PUPPET container_cli: CONTAINER_CLI + container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET @@ -653,6 +668,7 @@ outputs: DEPLOY_SOURCE_HOST: {get_param: deployment_source_hosts} DEPLOY_TARGET_HOST: {get_param: deployment_target_hosts} CONTAINER_CLI: {get_param: ContainerCli} + CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath} DEPLOY_IDENTIFIER: {get_param: DeployIdentifier} BOOTSTRAP_SERVER_ID: {get_attr: [BootstrapServerId, value]} ENABLE_DEBUG: {get_param: ConfigDebug} @@ -672,6 +688,7 @@ outputs: enable_debug: ENABLE_DEBUG enable_puppet: ENABLE_PUPPET container_cli: CONTAINER_CLI + container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET @@ -691,6 +708,7 @@ outputs: DOCKER_PUPPET_PROCESS_COUNT: {get_param: DockerPuppetProcessCount} DOCKER_PUPPET_MOUNT_HOST_PUPPET: {get_param: DockerPuppetMountHostPuppet} CONTAINER_CLI: {get_param: ContainerCli} + CONTAINER_LOG_STDOUT_PATH: {get_param: ContainerLogStdoutPath} template: | - hosts: DEPLOY_SOURCE_HOST name: Gather facts from undercloud @@ -724,6 +742,7 @@ outputs: enable_debug: ENABLE_DEBUG enable_puppet: ENABLE_PUPPET container_cli: CONTAINER_CLI + container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET @@ -749,6 +768,7 @@ outputs: enable_debug: ENABLE_DEBUG enable_puppet: ENABLE_PUPPET container_cli: CONTAINER_CLI + container_log_stdout_path: CONTAINER_LOG_STDOUT_PATH docker_puppet_debug: DOCKER_PUPPET_DEBUG docker_puppet_process_count: DOCKER_PUPPET_PROCESS_COUNT docker_puppet_mount_host_puppet: DOCKER_PUPPET_MOUNT_HOST_PUPPET diff --git a/docker/docker-puppet.py b/docker/docker-puppet.py index 0d469e3187..b092f8e0aa 100755 --- a/docker/docker-puppet.py +++ b/docker/docker-puppet.py @@ -33,6 +33,8 @@ from paunch import runner as containers_runner logger = None sh_script = '/var/lib/docker-puppet/docker-puppet.sh' 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 @@ -425,8 +427,9 @@ def mp_puppet_config(*args): common_dcmd.push('--privileged') if container_cli == 'podman': + log_path = os.path.join(container_log_stdout_path, uname) logging = ['--log-opt', - 'path=/var/log/containers/stdouts/%s.log' % uname] + 'path=%s.log' % log_path] common_dcmd.extend(logging) diff --git a/releasenotes/notes/ContainerLogStdoutPath-20cbce05a1710d8a.yaml b/releasenotes/notes/ContainerLogStdoutPath-20cbce05a1710d8a.yaml new file mode 100644 index 0000000000..6910cf05e3 --- /dev/null +++ b/releasenotes/notes/ContainerLogStdoutPath-20cbce05a1710d8a.yaml @@ -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.