From ef2ebb18d191968c083c3a8dbad62ceadcea2b72 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Wed, 4 Nov 2020 16:38:23 +0100 Subject: [PATCH] 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 Resolves: #1902922 NB: Slight conflict when cherry-picking due to different context Change-Id: If5487c9be745ebd6bc3ebe172e28dc59e6855188 (cherry picked from commit a9da212d7ddf6fb07ca749dd5967370df5b8419b) (cherry picked from commit d7d9e05ff8ff582cd9ff3bea24f4482de90de59b) (cherry picked from commit 29b8a69a896a963944c1ae8bf287f42173d8db49) --- deployment/memcached/memcached-container-puppet.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deployment/memcached/memcached-container-puppet.yaml b/deployment/memcached/memcached-container-puppet.yaml index 6abebdb7ae..0b7075793d 100644 --- a/deployment/memcached/memcached-container-puppet.yaml +++ b/deployment/memcached/memcached-container-puppet.yaml @@ -138,7 +138,7 @@ outputs: dport: 11211 proto: 'tcp' source: {get_param: MemcachedIpSubnet} - memcached::logfile: '/var/log/memcached/memcached.log' + memcached::logstdout: true service_config_settings: collectd: tripleo.collectd.plugins.memcached: @@ -156,7 +156,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: "/"