diff --git a/manifests/profile/base/logging/logrotate.pp b/manifests/profile/base/logging/logrotate.pp index 459091d78..d1b6ac560 100644 --- a/manifests/profile/base/logging/logrotate.pp +++ b/manifests/profile/base/logging/logrotate.pp @@ -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', diff --git a/releasenotes/notes/logrotate-copytruncate-hourly-f0851bec551f5f5f.yaml b/releasenotes/notes/logrotate-copytruncate-hourly-f0851bec551f5f5f.yaml new file mode 100644 index 000000000..1e9e716a1 --- /dev/null +++ b/releasenotes/notes/logrotate-copytruncate-hourly-f0851bec551f5f5f.yaml @@ -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). diff --git a/templates/logrotate/containers_logrotate.conf.erb b/templates/logrotate/containers_logrotate.conf.erb index 2aa743a28..8bf2b7739 100644 --- a/templates/logrotate/containers_logrotate.conf.erb +++ b/templates/logrotate/containers_logrotate.conf.erb @@ -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 }