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 <sgolovat@redhat.com>
Co-authored-by: Alex Schultz <aschultz@redhat.com>
Closes-bug: #1776889

Change-Id: I3b5aec6b7f7c5fa4f84e3c3eb243c155a6189e2c
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
This commit is contained in:
Bogdan Dobrelya 2018-06-15 10:47:20 +03:00
parent e09ef3df9d
commit c9c0fcf945
2 changed files with 9 additions and 28 deletions

View File

@ -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

View File

@ -0,0 +1,5 @@
---
upgrade:
- |
Containerized memcached logs to stdout/stderr instead of a file.
Its logs may be picked up via journald.