Merge "Fix containerized logrotate configuration"
This commit is contained in:
@@ -50,6 +50,10 @@
|
|||||||
# [*user*]
|
# [*user*]
|
||||||
# (optional) Defaults to 'root'. Configures cron job for logrotate.
|
# (optional) Defaults to 'root'. Configures cron job for logrotate.
|
||||||
#
|
#
|
||||||
|
# [*copytruncate*]
|
||||||
|
# (optional) Defaults to True.
|
||||||
|
# Configures the logrotate copytruncate parameter.
|
||||||
|
#
|
||||||
# [*delaycompress*]
|
# [*delaycompress*]
|
||||||
# (optional) Defaults to True.
|
# (optional) Defaults to True.
|
||||||
# Configures the logrotate delaycompress parameter.
|
# Configures the logrotate delaycompress parameter.
|
||||||
@@ -63,11 +67,11 @@
|
|||||||
# Configures the logrotate maxsize parameter.
|
# Configures the logrotate maxsize parameter.
|
||||||
#
|
#
|
||||||
# [*rotation*]
|
# [*rotation*]
|
||||||
# (optional) Defaults to 'daily'.
|
# (optional) Defaults to 'hourly'.
|
||||||
# Configures the logrotate rotation interval.
|
# Configures the logrotate rotation interval.
|
||||||
#
|
#
|
||||||
# [*rotate*]
|
# [*rotate*]
|
||||||
# (optional) Defaults to 14.
|
# (optional) Defaults to 336 (corresponds to 14 days).
|
||||||
# Configures the logrotate rotate parameter.
|
# Configures the logrotate rotate parameter.
|
||||||
#
|
#
|
||||||
# [*purge_after_days*]
|
# [*purge_after_days*]
|
||||||
@@ -91,11 +95,12 @@ class tripleo::profile::base::logging::logrotate (
|
|||||||
$weekday = '*',
|
$weekday = '*',
|
||||||
Integer $maxdelay = 90,
|
Integer $maxdelay = 90,
|
||||||
$user = 'root',
|
$user = 'root',
|
||||||
|
$copytruncate = true,
|
||||||
$delaycompress = true,
|
$delaycompress = true,
|
||||||
$compress = true,
|
$compress = true,
|
||||||
$rotation = 'daily',
|
$rotation = 'hourly',
|
||||||
$maxsize = '10M',
|
$maxsize = '10M',
|
||||||
$rotate = 14,
|
$rotate = 336,
|
||||||
$purge_after_days = 14,
|
$purge_after_days = 14,
|
||||||
# DEPRECATED PARAMETERS
|
# DEPRECATED PARAMETERS
|
||||||
$size = undef,
|
$size = undef,
|
||||||
|
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
upgrade:
|
||||||
|
- |
|
||||||
|
Logrotate's copytruncate is used by default for containerized services logs
|
||||||
|
rotation. The default period to keep old logs remains unchanged (14 days),
|
||||||
|
but rotation will happen on hourly basis instead of daily. That means that
|
||||||
|
old log files will be maintained for 336 versions of it, which represents
|
||||||
|
14 days multiplied by 24 hours per a day.
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Containerized logrotate configuration ensures httpd processes running in
|
||||||
|
containers will be reloaded gracefully via SIGUSR1. Containerized servicies
|
||||||
|
will reliably reopen its logfiles when logrotate happens.
|
@@ -10,6 +10,9 @@
|
|||||||
maxsize <%= @maxsize %>
|
maxsize <%= @maxsize %>
|
||||||
missingok
|
missingok
|
||||||
notifempty
|
notifempty
|
||||||
|
<%- if @copytruncate %>
|
||||||
|
copytruncate
|
||||||
|
<%- end %>
|
||||||
<%- if @delaycompress %>
|
<%- if @delaycompress %>
|
||||||
delaycompress
|
delaycompress
|
||||||
<%- end %>
|
<%- end %>
|
||||||
@@ -22,8 +25,11 @@
|
|||||||
\( -mtime +<%= @purge_after_days %> -or \
|
\( -mtime +<%= @purge_after_days %> -or \
|
||||||
-atime +<%= @purge_after_days %> -or \
|
-atime +<%= @purge_after_days %> -or \
|
||||||
-ctime +<%= @purge_after_days %> \) -exec rm -f {} \;;
|
-ctime +<%= @purge_after_days %> \) -exec rm -f {} \;;
|
||||||
/sbin/lsof -nPs +L1 +D /var/log/containers 2>&1|\
|
/sbin/lsof -nPs <%- if @copytruncate -%>+L1<%- end -%> +D /var/log/containers 2>&1|\
|
||||||
awk '/\S+\s+[0-9]+\s.*\/var\/log\/containers\/.*\(deleted\)/ {print $2}' |\
|
awk '/\S+\s+[0-9]+\s.*\/var\/log\/containers\/<%- if @copytruncate -%>.*\(deleted\)<%- end -%>/ {print $2}' |\
|
||||||
sort -u | /bin/xargs -n1 -r -t kill -HUP
|
sort -u | grep -v httpd | /bin/xargs -n1 -r -t kill -HUP;
|
||||||
|
/sbin/lsof -nPs <%- if @copytruncate -%>+L1<%- end -%> +D /var/log/containers/httpd 2>&1|\
|
||||||
|
awk '/\S+\s+[0-9]+\s.*\/var\/log\/containers\/httpd\/<%- if @copytruncate -%>.*\(deleted\)<%- end -%>/ {print $2}' |\
|
||||||
|
sort -u | /bin/xargs -n1 -r -t kill -USR1
|
||||||
endscript
|
endscript
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user