/var/log/containers/*/*log /var/log/containers/*/*/*log {
  <%= @rotation %>
  rotate <%= @rotate %>
  maxage <%= @purge_after_days %>
  # minsize 1 is required for GDPR compliance, all files in
  # /var/log/containers not managed with logrotate will be purged!
  minsize 1
  # Do not use size as it's not compatible with time-based rotation rules
  # required for GDPR compliance.
  maxsize <%= @maxsize %>
  missingok
  notifempty
<%- if @delaycompress %>
  delaycompress
<%- end %>
<%- if @compress %>
  compress
<%- end %>
  sharedscripts
  postrotate
    /usr/bin/find /var/log/containers -type f \
    \( -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>&1|\
    awk '/\S+\s+[0-9]+\s.*\/var\/log\/containers\/.*\(deleted\)/ {print $2}' |\
    sort -u | /bin/xargs -n1 -r -t kill -HUP
  endscript
}
