From 9c23160cad3ea6c8a702e1e3197c41619961cc22 Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Robles Date: Thu, 26 Oct 2017 08:52:37 +0300 Subject: [PATCH] Add rsyslog sidecar image for container image prepare Some services (namely HAProxy and swift) use syslog for their logging, and will need a sidecar container that runs rsyslog to redirect the logs to stdout. So, when these services are enabled and we set the variable "logging" to "stdout", we then enable the rsyslog container image as a parameter. The rsyslog-base image was used since we don't need any plugins for the sidecar container. bp logging-stdout-rsyslog Change-Id: I1bb6db4a80c601790800a6d5657c9f114d0d8e74 --- container-images/overcloud_containers.yaml | 1 + container-images/overcloud_containers.yaml.j2 | 11 ++++++ tripleo_common/image/kolla_builder.py | 3 +- .../tests/image/test_kolla_builder.py | 39 ++++++++++++++++--- 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/container-images/overcloud_containers.yaml b/container-images/overcloud_containers.yaml index 13ecdb6c4..d1383431e 100644 --- a/container-images/overcloud_containers.yaml +++ b/container-images/overcloud_containers.yaml @@ -92,3 +92,4 @@ container_images: - imagename: tripleoupstream/centos-binary-tacker:latest - imagename: tripleoupstream/centos-binary-zaqar:latest - imagename: docker.io/ceph/daemon:tag-stable-3.0-jewel-centos-7 +- imagename: tripleoupstream/centos-binary-rsyslog-base:latest diff --git a/container-images/overcloud_containers.yaml.j2 b/container-images/overcloud_containers.yaml.j2 index e10db1407..99f5b9ea6 100644 --- a/container-images/overcloud_containers.yaml.j2 +++ b/container-images/overcloud_containers.yaml.j2 @@ -672,3 +672,14 @@ container_images_template: - OS::TripleO::Services::CephOSD - OS::TripleO::Services::CephRgw - OS::TripleO::Services::CephRbdMirror + +{% if logging == "stdout" %} +- imagename: "{{namespace}}/{{name_prefix}}rsyslog-base{{name_suffix}}:{{tag}}" + params: + - DockerRsyslogSidecarImage + - DockerRsyslogSidecarConfigImage + services: + - OS::TripleO::Services::HAproxy + - OS::TripleO::Services::SwiftProxy + - OS::TripleO::Services::SwiftStorage +{% endif %} diff --git a/tripleo_common/image/kolla_builder.py b/tripleo_common/image/kolla_builder.py index 05cce1f4d..3e7a262dc 100644 --- a/tripleo_common/image/kolla_builder.py +++ b/tripleo_common/image/kolla_builder.py @@ -33,7 +33,8 @@ CONTAINER_IMAGES_DEFAULTS = { 'name_prefix': 'centos-binary-', 'name_suffix': '', 'tag': 'latest', - 'neutron_driver': None + 'neutron_driver': None, + 'logging': 'files' } diff --git a/tripleo_common/tests/image/test_kolla_builder.py b/tripleo_common/tests/image/test_kolla_builder.py index 40367e46e..06d52402a 100644 --- a/tripleo_common/tests/image/test_kolla_builder.py +++ b/tripleo_common/tests/image/test_kolla_builder.py @@ -169,6 +169,7 @@ class TestKollaImageBuilderTemplate(base.TestCase): 'ceph_namespace': 'docker.io/ceph', 'ceph_image': 'daemon', 'ceph_tag': 'tag-stable-3.0-jewel-centos-7', + 'logging': 'files', 'name_prefix': 'centos-binary-', 'name_suffix': '', 'tag': 'latest', @@ -183,6 +184,7 @@ class TestKollaImageBuilderTemplate(base.TestCase): 'ceph_namespace': 'docker.io/cephh', 'ceph_image': 'ceph-daemon', 'ceph_tag': 'latest', + 'logging': 'stdout', 'name_prefix': 'prefix-', 'name_suffix': '-suffix', 'tag': 'master', @@ -196,7 +198,8 @@ class TestKollaImageBuilderTemplate(base.TestCase): name_prefix='prefix', name_suffix='suffix', tag='master', - neutron_driver='ovn' + neutron_driver='ovn', + logging='stdout' ) ) @@ -236,7 +239,8 @@ class TestKollaImageBuilderTemplate(base.TestCase): self.assertEqual(container_images, result) def _test_container_images_yaml_in_sync_helper(self, neutron_driver=None, - remove_images=[]): + remove_images=[], + logging='files'): '''Confirm overcloud_containers.tpl.yaml equals overcloud_containers.yaml TODO(sbaker) remove when overcloud_containers.yaml is deleted @@ -256,7 +260,7 @@ class TestKollaImageBuilderTemplate(base.TestCase): return entry result = tmpl_builder.container_images_from_template( - filter=ffunc, neutron_driver=neutron_driver) + filter=ffunc, neutron_driver=neutron_driver, logging=logging) oc_yaml_file = os.path.join(files_dir, 'overcloud_containers.yaml') yaml_builder = kb.KollaImageBuilder([oc_yaml_file]) @@ -285,7 +289,8 @@ class TestKollaImageBuilderTemplate(base.TestCase): {'imagename': 'tripleoupstream/centos-binary-ovn-' 'nb-db-server:latest'}, {'imagename': 'tripleoupstream/centos-binary-ovn-' - 'sb-db-server:latest'}] + 'sb-db-server:latest'}, + {'imagename': 'tripleoupstream/centos-binary-rsyslog-base:latest'}] self._test_container_images_yaml_in_sync_helper( remove_images=remove_images) @@ -303,7 +308,8 @@ class TestKollaImageBuilderTemplate(base.TestCase): {'imagename': 'tripleoupstream/centos-binary-ovn-' 'nb-db-server:latest'}, {'imagename': 'tripleoupstream/centos-binary-ovn-' - 'sb-db-server:latest'}] + 'sb-db-server:latest'}, + {'imagename': 'tripleoupstream/centos-binary-rsyslog-base:latest'}] self._test_container_images_yaml_in_sync_helper( neutron_driver='odl', remove_images=remove_images) @@ -314,6 +320,27 @@ class TestKollaImageBuilderTemplate(base.TestCase): {'imagename': 'tripleoupstream/centos-binary' '-neutron-server-opendaylight:latest'}, {'imagename': 'tripleoupstream/centos-binary' - '-opendaylight:latest'}] + '-opendaylight:latest'}, + {'imagename': 'tripleoupstream/centos-binary' + '-rsyslog-base:latest'}] self._test_container_images_yaml_in_sync_helper( neutron_driver='ovn', remove_images=remove_images) + + def test_container_images_yaml_in_sync_for_stdout_logging(self): + remove_images = [ + {'imagename': 'tripleoupstream/centos-binary' + '-neutron-server-opendaylight:latest'}, + {'imagename': 'tripleoupstream/centos-binary' + '-neutron-server-ovn:latest'}, + {'imagename': 'tripleoupstream/centos-binary-ovn-base:latest'}, + {'imagename': 'tripleoupstream/centos-binary' + '-opendaylight:latest'}, + {'imagename': 'tripleoupstream/centos-binary-ovn-northd:latest'}, + {'imagename': 'tripleoupstream/centos-binary-ovn-' + 'controller:latest'}, + {'imagename': 'tripleoupstream/centos-binary-ovn-' + 'nb-db-server:latest'}, + {'imagename': 'tripleoupstream/centos-binary-ovn-' + 'sb-db-server:latest'}] + self._test_container_images_yaml_in_sync_helper( + remove_images=remove_images, logging='stdout')