From c9c0fcf945d976dda248b52c5a23a9cf895be777 Mon Sep 17 00:00:00 2001 From: Bogdan Dobrelya Date: Fri, 15 Jun 2018 10:47:20 +0300 Subject: [PATCH] Log memcached to stdout/err only Memcached logging configuration is not friendly. We cannot use configuration options as they seemed to be ignored because of a bug. We cannot use redirection >> as this breaks logrotate signalling SIGHUP to processes and expecting them to handle the open file descriptors associated with truncated/removed logfiles - this does not work with redirected output into a file. The only option is not log memcached into a file. There is not much of actual value in the log. Keep it logging to stdout/stderr in its container, which will get captured in the docker logs (and journald via the logging backend). Co-authored-by: Sergii Golovatiuk Co-authored-by: Alex Schultz Closes-bug: #1776889 Change-Id: I3b5aec6b7f7c5fa4f84e3c3eb243c155a6189e2c Signed-off-by: Bogdan Dobrelya --- docker/services/memcached.yaml | 32 +++---------------- .../memcached_logging-f69ade3665a70a5c.yaml | 5 +++ 2 files changed, 9 insertions(+), 28 deletions(-) create mode 100644 releasenotes/notes/memcached_logging-f69ade3665a70a5c.yaml diff --git a/docker/services/memcached.yaml b/docker/services/memcached.yaml index 4e12dad387..4638a2f645 100644 --- a/docker/services/memcached.yaml +++ b/docker/services/memcached.yaml @@ -71,19 +71,9 @@ outputs: kolla_config: {} docker_config: step_1: - memcached_init_logs: - start_order: 0 - detach: false - image: &memcached_image {get_param: DockerMemcachedImage} - privileged: false - user: root - volumes: - - /var/lib/config-data/memcached/etc/sysconfig/memcached:/etc/sysconfig/memcached:ro - - /var/log/containers/memcached:/var/log/ - command: ['/bin/bash', '-c', 'source /etc/sysconfig/memcached; touch /var/log/memcached.log && chown ${USER} /var/log/memcached.log'] memcached: - start_order: 1 - image: *memcached_image + start_order: 0 + image: {get_param: DockerMemcachedImage} net: host privileged: false restart: always @@ -94,27 +84,13 @@ outputs: - {get_attr: [ContainersCommon, volumes]} - - /var/lib/config-data/memcached/etc/sysconfig/memcached:/etc/sysconfig/memcached:ro - - /var/log/containers/memcached:/var/log/ - # NOTE: We're adding the log redirection here, even though should - # already be part of the options. This is because the redirection - # via the options is not working and ends up being passed as a - # parameter to the memcached command (which it silently ignores). - # Thus the need for the explicit redirection here. The redirection - # will be removed from the $OPTIONS, which is done via the puppet - # module, but we'll only be able to do this once the following pull - # request merges: https://github.com/saz/puppet-memcached/pull/88 - command: ['/bin/bash', '-c', 'source /etc/sysconfig/memcached; /usr/bin/memcached -p ${PORT} -u ${USER} -m ${CACHESIZE} -c ${MAXCONN} -X $OPTIONS >> /var/log/memcached.log 2>&1'] + command: ['/bin/bash', '-c', 'source /etc/sysconfig/memcached; /usr/bin/memcached -p ${PORT} -u ${USER} -m ${CACHESIZE} -c ${MAXCONN} $OPTIONS'] host_prep_tasks: - - name: create persistent logs directory - file: - path: /var/log/containers/memcached - state: directory - name: memcached logs readme copy: dest: /var/log/memcached-readme.txt content: | - Log files from memcached containers can be found under - /var/log/containers/memcached. + Memcached container logs to stdout/stderr only. ignore_errors: true upgrade_tasks: - when: step|int == 0 diff --git a/releasenotes/notes/memcached_logging-f69ade3665a70a5c.yaml b/releasenotes/notes/memcached_logging-f69ade3665a70a5c.yaml new file mode 100644 index 0000000000..45878d7e28 --- /dev/null +++ b/releasenotes/notes/memcached_logging-f69ade3665a70a5c.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - | + Containerized memcached logs to stdout/stderr instead of a file. + Its logs may be picked up via journald.