Bug 1939964

Summary: [RHOSP 16.1] [rsyslog] rsyslog containers does not forward logs to elasticsearch
Product: Red Hat OpenStack Reporter: Firozkhan <fgadkano>
Component: openstack-tripleo-heat-templatesAssignee: OSP Team <rhos-maint>
Status: CLOSED ERRATA QA Contact: Leonid Natapov <lnatapov>
Severity: medium Docs Contact:
Priority: medium    
Version: 16.1 (Train)CC: cgaynor, enothen, jamsmith, lmadsen, mburns, mmagr, mrunge, nchandek, youngkim
Target Milestone: z8Keywords: Triaged, ZStream
Target Release: 16.1 (Train on RHEL 8.2)Flags: fgadkano: needinfo-
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: openstack-tripleo-heat-templates-11.3.2-1.20210817183308.29a02c1.el8ost, puppet-tripleo-11.5.0-1.20210817133311.f716ef5.el8ost Doc Type: Enhancement
Doc Text:
Enable the experimental `rsyslog reopenOnTruncate` to ensure that rsyslog immediately recognizes when a logrotation happens on a file. The setting affects every service configured to work with rsyslog. + With `rsyslog reopenOnTruncate` disabled, rsyslog waits for a log file to fill to its original capacity before consuming any additional logs.
Story Points: ---
Clone Of:
: 1949673 1949675 (view as bug list) Environment:
Last Closed: 2022-03-24 10:59:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1949675    

Comment 10 Martin Magr 2021-04-22 13:32:46 UTC
I was able to verify that reopenOnTruncate="on" works for me with rsyslog-8.1911.0-6.el8.x86_64. I found out that it did not use to work properly ([1]) and had been patched in the past. Not sure which rsyslog version is used in 16.1 container. Can you please get me a NVR used so I can check that the patch is in version used?

[1] https://github.com/rsyslog/rsyslog/issues/1090

Comment 14 Paul Leimer 2021-05-04 21:34:10 UTC
I was able to reproduce this in OSP16.1.6 with the following process, even after setting `reopenOnTruncate="on"` in `/var/lib/config-data/puppet-generated/rsyslog/etc/rsyslog.d/50_openstack_logs.conf`.

The problem is not a fault of rsyslog, and the `reopenOnTruncate` is the correct option to set to ensure the expected behaviour. However, adjustments to the mentioned config file are not being mounted into the rsyslog container when they are made manually, and thus `reopenOnTruncate` is never set in `/etc/rsyslog.d/50_openstack_logs.conf` within the container.

Comment 19 Paul Leimer 2021-06-16 12:40:17 UTC
Try the same workaround as mentioned above: 

1. Within /var/lib/config-data/puppet-generated/rsyslog/etc/rsyslog.d/50_openstack_logs.conf on each node, add the reopenOnTruncate="on" parameter to each input block.

For example:

> input(type="imfile"
>   file="/var/log/containers/glance/api.log"
>   tag="openstack.glance.api"
>   startmsg.regex="^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.[0-9]+ [0-9]+)? (DEBUG|INFO|WARNING|ERROR) "
>   reopenOnTruncate="on"  # <------------ new parameter
> )

2. Restart the rsyslog container with

$ podman restart rsyslog

3. Verify that the configuration change took affect in the container:

$ podman exec rsyslog cat /etc/rsyslog.d/50_openstack_logs.conf

Comment 28 Eric Nothen 2021-12-15 12:40:10 UTC
I created the following Ansible playbook to insert the change in an idempotent way, since it needs to be done after each overcloud update for the time being:

[stack.lab ~]$ cat ./insert-rsyslog-fix.yaml 
- name: This playbooks adds a custom line to the rsyslog configuration file
  hosts: Controller
  gather_facts: False
  become: True

  tasks:
    - name: Insert reopenOnTruncate on 50_openstack_logs.conf
      ansible.builtin.replace:
        path: /var/lib/config-data/puppet-generated/rsyslog/etc/rsyslog.d/50_openstack_logs.conf
        regexp: '^(  file=.*$\n)(?!  reopenOnTruncate="on")'
        replace: '\1  reopenOnTruncate="on"\n'
      register: fix

    - name: Restart rsyslog container
      shell: podman restart rsyslog
      when: fix.changed


Run it from the undercloud using the inventory generated by tripleo:

[stack.lab ~]$ ansible-playbook -i inventory.yaml ./insert-rsyslog-fix.yaml

PLAY [This playbooks adds a custom line to the rsyslog configuration file] *********************************************************************************************************************************************************************************

TASK [Insert reopenOnTruncate on 50_openstack_logs.conf] ***************************************************************************************************************************************************************************************************
changed: [overcloud-controller-0]
changed: [overcloud-controller-2]
changed: [overcloud-controller-1]

TASK [Restart rsyslog container] ***************************************************************************************************************************************************************************************************************************
changed: [overcloud-controller-2]
changed: [overcloud-controller-0]
changed: [overcloud-controller-1]

PLAY RECAP *************************************************************************************************************************************************************************************************************************************************
overcloud-controller-0     : ok=2    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
overcloud-controller-1     : ok=2    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
overcloud-controller-2     : ok=2    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

[stack.lab ~]$

Comment 29 Eric Nothen 2021-12-15 14:33:25 UTC
(In reply to Eric Nothen from comment #28)
> I created the following Ansible playbook to insert the change in an
> idempotent way, since it needs to be done after each overcloud update for
> the time being:
> 
> [stack.lab ~]$ cat ./insert-rsyslog-fix.yaml 
> - name: This playbooks adds a custom line to the rsyslog configuration file
>   hosts: Controller
> 

hosts should be:

  hosts: Compute:Controller

Comment 32 Leonid Natapov 2022-02-01 12:05:59 UTC
tested on 16.1.8

Comment 39 errata-xmlrpc 2022-03-24 10:59:07 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Red Hat OpenStack Platform 16.1.8 bug fix and enhancement advisory), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:0986