Merge "Copytruncate containerized logrotate configuration"

This commit is contained in:
Zuul 2018-10-10 22:06:58 +00:00 committed by Gerrit Code Review
commit c0f568ef97
3 changed files with 14 additions and 8 deletions

View File

@ -50,6 +50,10 @@
# [*user*]
# (optional) Defaults to 'root'. Configures cron job for logrotate.
#
# [*copytruncate*]
# (optional) Defaults to True.
# Configures the logrotate copytruncate parameter.
#
# [*delaycompress*]
# (optional) Defaults to True.
# Configures the logrotate delaycompress parameter.
@ -91,6 +95,7 @@ class tripleo::profile::base::logging::logrotate (
$weekday = '*',
Integer $maxdelay = 90,
$user = 'root',
$copytruncate = true,
$delaycompress = true,
$compress = true,
$rotation = 'daily',

View File

@ -0,0 +1,5 @@
---
upgrade:
- |
Logrotate's copytruncate is used by default for containerized services logs
rotation. The default period to keep old logs remains unchanged (14 days).

View File

@ -1,4 +1,4 @@
/var/log/containers/*/*log /var/log/containers/*/*/*log {
/var/log/containers/*/*log /var/log/containers/*/*/*log /var/log/containers/*/*err {
<%= @rotation %>
rotate <%= @rotate %>
maxage <%= @purge_after_days %>
@ -10,6 +10,9 @@
maxsize <%= @maxsize %>
missingok
notifempty
<%- if @copytruncate %>
copytruncate
<%- end %>
<%- if @delaycompress %>
delaycompress
<%- end %>
@ -22,12 +25,5 @@
\( -mtime +<%= @purge_after_days %> -or \
-atime +<%= @purge_after_days %> -or \
-ctime +<%= @purge_after_days %> \) -exec rm -f {} \;;
/sbin/lsof -nPs +L1 +D /var/log/containers 2>/dev/null|\
grep -v /var/log/httpd/ |\
awk '/\S+\s+[0-9]+\s.*\/var\/log\/.*\(deleted\)/ {print $2}' |\
sort -u | /bin/xargs -n1 -r -t kill -HUP;
/sbin/lsof -nPs +L1 +D /var/log/containers 2>/dev/null|\
awk '/\S+\s+[0-9]+\s.*\/var\/log\/httpd\/.*\(deleted\)/ {print $2}' |\
sort -u | /bin/xargs -n1 -r -t kill -USR1
endscript
}