Bug 1320955 - logrotate does not rotate certain log files
Summary: logrotate does not rotate certain log files
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: logrotate
Version: 7.1
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Kamil Dudka
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
: 1667046 (view as bug list)
Depends On:
Blocks: 1298243 1398314 1420851 1451294
TreeView+ depends on / blocked
 
Reported: 2016-03-24 11:08 UTC by Nikola Stiasni
Modified: 2020-09-10 09:34 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-17 12:39:44 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Nikola Stiasni 2016-03-24 11:08:06 UTC
Description of problem:

Customer has the following configuration in /etc/logrotate.d/rsyslog:

# Linux/Unix
#
/local/rsyslog/auth 
/local/rsyslog/kernel 
/local/rsyslog/news 
/local/rsyslog/cron 
/local/rsyslog/goldengate 
/local/rsyslog/mail 
/local/rsyslog/sftp_automatic
/local/rsyslog/sftp
/local/rsyslog/siem
/local/rsyslog/rest {

    daily
    notifempty
    rotate 1500
    create
    nodateext
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

#
# Cluster-Mode NetApp
#
/local/rsyslog/f1fsp1
/local/rsyslog/f1fsp2
/local/rsyslog/f1fsp3
/local/rsyslog/f1fsp4
/local/rsyslog/f1fsnld1
/local/rsyslog/f1fsnld2
/local/rsyslog/deengfsn11
/local/rsyslog/deengfsn12 {

    daily
    notifempty
    compress
    rotate 1500
    create
    nodateext
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

#
# ESX servers
#
/local/rsyslog/sdrsappesxp
/local/rsyslog/sdrsappesxz
/local/rsyslog/sdrsdeesxp
/local/rsyslog/sdrsspsesx
/local/rsyslog/sdrspdfesxp
/local/rsyslog/sdrsspsesxp
/local/rsyslog/sdrsuxesxp
/local/rsyslog/sdrsesxd
/local/rsyslog/sdrsesxp
/local/rsyslog/sdrsesxz
/local/rsyslog/sdrsesxl
/local/rsyslog/f1esxd
/local/rsyslog/sfc1esx
/local/rsyslog/sdrspeesx
/local/rsyslog/saldesx
/local/rsyslog/sdrsvcesx
/local/rsyslog/sdrsvcesxl
/local/rsyslog/sdrsvcesxp {

    daily
    notifempty
    compress
    rotate 30
    create
    nodateext
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

These entries can be split into 3 files, however, this does not change the underlying issue.
Customer claims that some files, for example "/local/rsyslog/sdrsappesxz", are not being rotated despite the message that file needs to be rotated.

Older rotated files were all deleted by the customer, so logrotate kept producing the errors:

renaming /local/rsyslog/sdrsappesxz.30.gz to /local/rsyslog/sdrsappesxz.31.gz (rotatecount 30, logstart 1, i 30),
old log /local/rsyslog/sdrsappesxz.30.gz does not exist
renaming /local/rsyslog/sdrsappesxz.29.gz to /local/rsyslog/sdrsappesxz.30.gz (rotatecount 30, logstart 1, i 29),
old log /local/rsyslog/sdrsappesxz.29.gz does not exist

By adding "missingok" to his config file, customer said that "
adding "missingok" to my config (please see below) made logrotate rotate all files."
However, he thinks there is a bug with logrotate:
"I had so many _existing_ files that were not rotated by logrotate as configured (comparing to the description of "missingok") I still consider this a logrotate bug."

Version-Release number of selected component (if applicable):
logrotate-3.8.6-7.el7_2.x86_64

How reproducible:
I could not reproduce his issue no matter what I did. I copied his config file to my RHEL 7 server and all logs kept rotating as expected.

Comment 3 Zdenek Pytela 2016-06-29 15:26:14 UTC
I took over this bugzilla and the support case which initiated it. Just managed to nail down the configuration to reproduce.

Let's have this /etc/logrotate.d/test logrotate configuration file:

/local/rsyslog/existing
/local/rsyslog/nonexist {
    daily
    rotate 2
    create
    nodateext
    #missingok
    #sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

The first file exist, the second one does not.

When logrotate is run (logrotate -vf /etc/logrotate.d/test), the files are rotated fine. Once the sharedscripts directive is uncommented, the commands output look fine at first glance, older logs are rotated, but the actual log is not; the command output misses these lines:

> fscreate context set to unconfined_u:object_r:default_t:s0
> renaming /local/rsyslog/existing to /local/rsyslog/existing.1
> creating new /local/rsyslog/existing mode = 0644 uid = 0 gid = 0
> running postrotate script

If missingok directive is uncommented as well, it works again. In the logrotate(8) manual page, the sharedscripts option is described as follows:

       sharedscripts
              Normally, prerotate and postrotate scripts are run for each log which is  rotated
              and  the absolute path to the log file is passed as first argument to the script.
              That means a single script may be run multiple times for log file  entries  which
              match  multiple  files (such as the /var/log/news/* example). If sharedscripts is
              specified, the scripts are only run once, no matter how many logs match the wild‐
              carded  pattern,  and  whole  pattern is passed to them.  However, if none of the
              logs in the pattern require rotating, the scripts will not be run at all. If  the
              scripts exit with error, the remaining actions will not be executed for any logs.
              This option overrides the nosharedscripts option and implies create option.


Seems just like misunderstanding now, or different interpretation how the rotation should work according to the options combination. The customer uses the configuration this way, and forces the rotation with -f switch. Could we have this clarified?

Comment 4 Kamil Dudka 2016-06-30 17:02:39 UTC
I agree this is a bug.  See bug #1196583 comment #3 for the cause and the fix.  The problem is that the fix caused another issue and has already been reverted upstream.

Could the missingok option be used as a workaround for the customer?

Comment 5 Zdenek Pytela 2016-07-01 14:42:59 UTC
Hi Kamil,

I was far from stating this being a logrotate bug; for me it was more like unclear documentation. It looks different now, thanks for the link.

I asked our customer if he is satisfied with the workaround for now.

Is there any reason for keeping this bug private?

Comment 6 Kamil Dudka 2016-07-01 16:06:37 UTC
(In reply to Zdenek Pytela from comment #5)
> I asked our customer if he is satisfied with the workaround for now.

Thanks!  The reason I am asking is that the fix in question introduces a change in behavior, which we try to avoid in RHEL, if possible, in order not to break existing solutions of our customers.

> Is there any reason for keeping this bug private?

Not that I know of.

Comment 7 Zdenek Pytela 2016-07-06 07:31:56 UTC
Currently, customer is satisfied with using the "missingok" option as a workaround, but he is interested in participation in this bugzilla and future development.

I am making this bug public.

Comment 12 Kamil Dudka 2017-08-01 12:16:40 UTC
This bug is unlikely to be fixed in RHEL-7 because the proposed fix implies a change in behavior, which could break existing installations of logrtate that rely on the current behavior.  Note that the original fix for this bug has been already reverted upstream because it caused a regression in certain configurations.

Please consider using the "missingok" directive to work around this bug.

Comment 13 Kamil Dudka 2019-01-18 13:48:07 UTC
*** Bug 1667046 has been marked as a duplicate of this bug. ***

Comment 15 Kamil Dudka 2019-06-17 12:39:44 UTC
Per comment #12 closing CANTFIX.


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