Fix memcached logging

Even though we're setting memcached::logfile:
'/var/log/memcached/memcached.log' there are no logs created in
/var/log/containers/memcached.

The reason for this is that memcached::logfile in puppet-memcached
simply adds a shell redirect to a file. These redirecs are
passed by tht and kolla to the memcached process invocation as parameters
of memcached and so are not read being read by the shell process
and nothing gets redirected. That is why we observe that on a broken
container the redirections are arguments to memcached:

[root@controller-0 ~]# ps aux | grep memcache | grep -v containers
    42457     358189  0.0  0.0 744088 10960 ?        Sl   15:21   0:00 /usr/bin/memcached -p 11211 -u memcached -m 16000 -c 8192 -vv -l 172.17.1.138 -U 0 -X -t 8 >> /var/log/memcached/memcached.log 2>&1

Fix this by forcing memcached to log on stdout and at the same
time creating the redirect on the shell parameters that invoke
memcached.

Tested on a Train environment and I correctly get:
1) Proper logging
[root@controller-0 ~]# ls -l /var/log/containers/memcached/memcached.log
-rw-r--r--. 1 42457 42457 29086 Nov  4 18:00 /var/log/containers/memcached/memcached.log

2) No unused redirections inside the memcached process:
[root@controller-0 ~]# podman exec -it -uroot memcached ps -ef
UID          PID    PPID  C STIME TTY          TIME CMD
memcach+       1       0  0 18:47 ?        00:00:00 dumb-init --single-child -- kolla_start
memcach+       6       1  0 18:47 ?        00:00:00 /usr/bin/memcached -p 11211 -u memcached -m 9953 -c 8192 -vv -l 172.17.1.50 -U 0 -X -t 4

Co-Authored-By: Damien Ciabrini <dciabrin@redhat.com>

Resolves: #1902922

Change-Id: If5487c9be745ebd6bc3ebe172e28dc59e6855188
This commit is contained in:
Michele Baldessari 2020-11-04 16:38:23 +01:00
parent 0a1a16b606
commit a9da212d7d
1 changed files with 2 additions and 2 deletions

View File

@ -157,7 +157,7 @@ outputs:
- 'v'
- ''
memcached::disable_cachedump: true
memcached::logfile: '/var/log/memcached/memcached.log'
memcached::logstdout: true
tripleo::profile::base::memcached::enable_internal_memcached_tls: {get_param: MemcachedTLS}
-
if:
@ -196,7 +196,7 @@ outputs:
config_image: {get_param: ContainerMemcachedConfigImage}
kolla_config:
/var/lib/kolla/config_files/memcached.json:
command: bash -c $* -- eval source /etc/sysconfig/memcached; exec /usr/bin/memcached -p ${PORT} -u ${USER} -m ${CACHESIZE} -c ${MAXCONN} $OPTIONS
command: bash -c $* -- eval source /etc/sysconfig/memcached; exec /usr/bin/memcached -p ${PORT} -u ${USER} -m ${CACHESIZE} -c ${MAXCONN} $OPTIONS >> /var/log/memcached/memcached.log 2>&1
config_files:
- source: "/var/lib/kolla/config_files/src/*"
dest: "/"