RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2070623 - Move back to logrotate copytruncate method
Summary: Move back to logrotate copytruncate method
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: corosync
Version: CentOS Stream
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Jan Friesse
QA Contact: cluster-qe@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-03-31 15:02 UTC by Jan Friesse
Modified: 2022-11-15 11:26 UTC (History)
5 users (show)

Fixed In Version: corosync-3.1.5-4.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-11-15 10:25:11 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
logrotate: Use copytruncate method by default (2.18 KB, patch)
2022-03-31 15:05 UTC, Jan Friesse
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-117552 0 None None None 2022-03-31 15:22:01 UTC
Red Hat Product Errata RHBA-2022:8127 0 None None None 2022-11-15 10:25:13 UTC

Description Jan Friesse 2022-03-31 15:02:49 UTC
Description of problem:
The idea is to move back to logrotate copytruncate method. This method was used during RHEL 7/8, but with RHEL 9 it was changed to call cfgtool which can instruct corosync to reopen logs. This method - eventho may looks cleaner - actually has some drawbacks - mentioned in bug 2061277 and (stopped corosync) in description of commit https://github.com/corosync/corosync/commit/04362046c4a9d7307feb5b68341d567b7d0b94d6

Version-Release number of selected component (if applicable):
3.1.5-1

Comment 1 Jan Friesse 2022-03-31 15:05:19 UTC
Created attachment 1869741 [details]
logrotate: Use copytruncate method by default

logrotate: Use copytruncate method by default

The reopen lograte method has two main problems:
1. It does fail when corosync is not running (solvable by
   adding "|| true")
2. If (for some reason, like SELinux) cfgtool -L fails, logrotate
   fails and corosync keeps logging into old file. Added "|| true"
   makes situation even worse because logrotate removes file but
   corosync keeps logging into it.

Solution is to install copytruncate logrotate snip by default (and
keep reopen config file only for reference).

Signed-off-by: Jan Friesse <jfriesse>
Reviewed-by: Christine Caulfield <ccaulfie>

Comment 6 Patrik Hagara 2022-07-02 10:03:19 UTC
before fix
==========

> [root@virt-537 ~]# rpm -q corosync
> corosync-3.1.5-3.el9.x86_64
> [root@virt-537 ~]# cat /etc/logrotate.d/corosync 
> /var/log/cluster/corosync.log {
> 	missingok
> 	compress
> 	daily
> 	rotate 31
> 	minsize 2048
> 	notifempty
> 	nocreate
> 	postrotate
> 		/usr/sbin/corosync-cfgtool -L
> 	endscript
> }

1) logrotate while corosync is not running

> [root@virt-537 ~]# systemctl status corosync
> ○ corosync.service - Corosync Cluster Engine
>      Loaded: loaded (/usr/lib/systemd/system/corosync.service; disabled; vendor preset: disabled)
>      Active: inactive (dead)
>        Docs: man:corosync
>              man:corosync.conf
>              man:corosync_overview
> 
> Jul 02 13:58:20 virt-537.cluster-qe.lab.eng.brq.redhat.com corosync[54549]: Ringbuffer:
> Jul 02 13:58:20 virt-537.cluster-qe.lab.eng.brq.redhat.com corosync[54549]:  ->OVERWRITE
> Jul 02 13:58:20 virt-537.cluster-qe.lab.eng.brq.redhat.com corosync[54549]:  ->write_pt [50056]
> Jul 02 13:58:20 virt-537.cluster-qe.lab.eng.brq.redhat.com corosync[54549]:  ->read_pt [0]
> Jul 02 13:58:20 virt-537.cluster-qe.lab.eng.brq.redhat.com corosync[54549]:  ->size [2098176 words]
> Jul 02 13:58:20 virt-537.cluster-qe.lab.eng.brq.redhat.com corosync[54549]:  =>free [8192476 bytes]
> Jul 02 13:58:20 virt-537.cluster-qe.lab.eng.brq.redhat.com corosync[54549]:  =>used [200224 bytes]
> Jul 02 13:58:20 virt-537.cluster-qe.lab.eng.brq.redhat.com systemd[1]: corosync.service: Deactivated successfully.
> Jul 02 13:58:20 virt-537.cluster-qe.lab.eng.brq.redhat.com systemd[1]: Stopped Corosync Cluster Engine.
> Jul 02 13:58:20 virt-537.cluster-qe.lab.eng.brq.redhat.com systemd[1]: corosync.service: Consumed 3.380s CPU time.
> [root@virt-537 ~]# wc -l /var/log/cluster/corosync.log
> 59 /var/log/cluster/corosync.log
> [root@virt-537 ~]# logrotate --force /etc/logrotate.d/corosync 
> Could not initialize corosync configuration API error CS_ERR_LIBRARY
> error: error running non-shared postrotate script for /var/log/cluster/corosync.log of '/var/log/cluster/corosync.log '

result: logrotate fails

2) logrotate with non-working corosync-cfgtool

> [root@virt-537 ~]# chmod -x $(which corosync-cfgtool)
> [root@virt-537 ~]# systemctl start corosync
> [root@virt-537 ~]# wc -l /var/log/cluster/corosync.log
> 44 /var/log/cluster/corosync.log
> [root@virt-537 ~]# logrotate --force /etc/logrotate.d/corosync 
> logrotate_script: line 2: /usr/sbin/corosync-cfgtool: Permission denied
> error: error running non-shared postrotate script for /var/log/cluster/corosync.log of '/var/log/cluster/corosync.log '

result: logrotate fails


after fix
=========

> [root@virt-491 ~]# rpm -q corosync
> corosync-3.1.5-4.el9.x86_64
> [root@virt-491 ~]# cat /etc/logrotate.d/corosync 
> /var/log/cluster/corosync.log {
> 	missingok
> 	compress
> 	copytruncate
> 	daily
> 	rotate 31
> 	minsize 2048
> 	notifempty
> }

1) logrotate while corosync is not running

> [root@virt-491 ~]# systemctl status corosync
> ○ corosync.service - Corosync Cluster Engine
>      Loaded: loaded (/usr/lib/systemd/system/corosync.service; disabled; vendor preset: disabled)
>      Active: inactive (dead)
>        Docs: man:corosync
>              man:corosync.conf
>              man:corosync_overview
> 
> Jul 02 10:55:28 virt-491.cluster-qe.lab.eng.brq.redhat.com corosync[55387]: Ringbuffer:
> Jul 02 10:55:28 virt-491.cluster-qe.lab.eng.brq.redhat.com corosync[55387]:  ->OVERWRITE
> Jul 02 10:55:28 virt-491.cluster-qe.lab.eng.brq.redhat.com corosync[55387]:  ->write_pt [50285]
> Jul 02 10:55:28 virt-491.cluster-qe.lab.eng.brq.redhat.com corosync[55387]:  ->read_pt [0]
> Jul 02 10:55:28 virt-491.cluster-qe.lab.eng.brq.redhat.com corosync[55387]:  ->size [2098176 words]
> Jul 02 10:55:28 virt-491.cluster-qe.lab.eng.brq.redhat.com corosync[55387]:  =>free [8191560 bytes]
> Jul 02 10:55:28 virt-491.cluster-qe.lab.eng.brq.redhat.com corosync[55387]:  =>used [201140 bytes]
> Jul 02 10:55:28 virt-491.cluster-qe.lab.eng.brq.redhat.com systemd[1]: corosync.service: Deactivated successfully.
> Jul 02 10:55:28 virt-491.cluster-qe.lab.eng.brq.redhat.com systemd[1]: Stopped Corosync Cluster Engine.
> Jul 02 10:55:28 virt-491.cluster-qe.lab.eng.brq.redhat.com systemd[1]: corosync.service: Consumed 19min 3.341s CPU time.
> [root@virt-491 ~]# wc -l /var/log/cluster/corosync.log
> 15 /var/log/cluster/corosync.log
> [root@virt-491 ~]# logrotate --force /etc/logrotate.d/corosync 
> [root@virt-491 ~]# wc -l /var/log/cluster/corosync.log
> 0 /var/log/cluster/corosync.log
> [root@virt-491 ~]# cat /var/log/cluster/corosync.log.1.gz | gzip -d - | wc -l
> 15

result: logs successfully rotated with corosync not running

2) logrotate with non-working corosync-cfgtool

> [root@virt-491 ~]# chmod -x $(which corosync-cfgtool)
> [root@virt-491 ~]# systemctl start corosync
> [root@virt-491 ~]# wc -l /var/log/cluster/corosync.log
> 34 /var/log/cluster/corosync.log
> [root@virt-491 ~]# logrotate --force /etc/logrotate.d/corosync 
> [root@virt-491 ~]# wc -l /var/log/cluster/corosync.log
> 0 /var/log/cluster/corosync.log
> [root@virt-491 ~]# cat /var/log/cluster/corosync.log.1.gz | gzip -d - | wc -l
> 34

result: fixed logrotate config does not require corosync-cfgtool, log file rotation succeeds

Comment 8 errata-xmlrpc 2022-11-15 10:25:11 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 (corosync bug fix and enhancement update), 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:8127


Note You need to log in before you can comment on or make changes to this bug.