/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
}

/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>/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
}

Fix postrotate filter and httpd reloading signal
Fix postrotate filter and httpd reloading signal

The change I5029a4b9c76268455812696290aaf82f1a0c2c23 had caused a
regression so that the filter is stopped working and matches nothing.

The postscript command is executed inside of the logrotate-crond
container, like this way:

()[root@5c78303fb8c2 /]# /sbin/lsof -nPs +L1 +D /var/log/containers
2>&1 | awk '/\S+\s+[0-9]+\s.*\/var\/log\/.*\(deleted\)/ {print}'

neutron-s ... /var/log/neutron/server.log.1 (deleted)
httpd .../var/log/httpd/keystone_wsgi_admin_access.log.1 (deleted)

So you can see that the real path should be examined for deleted
(open and unlined) logs is /var/log/ and not /var/log/containers. The
latter is only used to apply the logrotation over the bind-mounted
host path. It cannot affect any host logs outside of
/var/log/containers, so the change
I5029a4b9c76268455812696290aaf82f1a0c2c23 needs to be partially
discarded.

Additionally, send USR1 instead of HUP to reload httpd in containers
gracefully. That part follows-up the reverted
I15fa0eab1625ac63fd57b6a6d5cd22a6ac85f221 as we want to keep that
change and it fits the subject bug scope as well.

Change-Id: Ibb017463b0fbbccda035aeb1fff5f6998bbf2d1e
Closes-Bug: #1776533
Related-Bug: #1785659
