[Bug 1320201] [NEW] behaviour in debug mode doesn't match real behaviour

Gertjan Oude Lohuis gertjan at oudelohuis.nl
Fri May 16 12:07:11 UTC 2014


Public bug reported:

Situation: a single log file (no earlier rotates) and a logrotate status
that says it is time to rotate.

# ls -l /var/log/mail.log*
-rw-r----- 1 syslog adm 287 May 16 11:27 /var/log/mail.log

# cat /var/lib/logrotate/status 
logrotate state -- version 2
"/var/log/mail.log" 2012-3-31

# cat /tmp/test.conf 
/var/log/mail.log
{
	rotate 4
	weekly
	missingok
	notifempty
	compress
	delaycompress
	sharedscripts
	postrotate
		reload rsyslog >/dev/null 2>&1 || true
	endscript
}

logrotate in debug mode will fail, because it simulates removing a non-
existing mail.log.5.gz:

# logrotate -d /tmp/test.conf; echo $?
reading config file /tmp/test.conf
reading config info for /var/log/mail.log


Handling 1 logs

rotating pattern: /var/log/mail.log
 weekly (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/mail.log
  log needs rotating
rotating log /var/log/mail.log, log->rotateCount is 4
dateext suffix '-20140516'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
previous log /var/log/mail.log.1 does not exist
renaming /var/log/mail.log.4.gz to /var/log/mail.log.5.gz (rotatecount 4, logstart 1, i 4), 
renaming /var/log/mail.log.3.gz to /var/log/mail.log.4.gz (rotatecount 4, logstart 1, i 3), 
renaming /var/log/mail.log.2.gz to /var/log/mail.log.3.gz (rotatecount 4, logstart 1, i 2), 
renaming /var/log/mail.log.1.gz to /var/log/mail.log.2.gz (rotatecount 4, logstart 1, i 1), 
renaming /var/log/mail.log.0.gz to /var/log/mail.log.1.gz (rotatecount 4, logstart 1, i 0), 
renaming /var/log/mail.log to /var/log/mail.log.1
running postrotate script
running script (multiple) with arg /var/log/mail.log
: "
		reload rsyslog >/dev/null 2>&1 || true
"
removing old log /var/log/mail.log.5.gz
error: error opening /var/log/mail.log.5.gz: No such file or directory
1


logrotate's real behaviour handles this situation correctly:

# logrotate -v /tmp/test.conf; echo $?
reading config file /tmp/test.conf
reading config info for /var/log/mail.log


Handling 1 logs

rotating pattern: /var/log/mail.log
 weekly (4 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/mail.log
  log needs rotating
rotating log /var/log/mail.log, log->rotateCount is 4
dateext suffix '-20140516'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
previous log /var/log/mail.log.1 does not exist
renaming /var/log/mail.log.4.gz to /var/log/mail.log.5.gz (rotatecount 4, logstart 1, i 4), 
old log /var/log/mail.log.4.gz does not exist
renaming /var/log/mail.log.3.gz to /var/log/mail.log.4.gz (rotatecount 4, logstart 1, i 3), 
old log /var/log/mail.log.3.gz does not exist
renaming /var/log/mail.log.2.gz to /var/log/mail.log.3.gz (rotatecount 4, logstart 1, i 2), 
old log /var/log/mail.log.2.gz does not exist
renaming /var/log/mail.log.1.gz to /var/log/mail.log.2.gz (rotatecount 4, logstart 1, i 1), 
old log /var/log/mail.log.1.gz does not exist
renaming /var/log/mail.log.0.gz to /var/log/mail.log.1.gz (rotatecount 4, logstart 1, i 0), 
old log /var/log/mail.log.0.gz does not exist
log /var/log/mail.log.5.gz doesn't exist -- won't try to dispose of it
renaming /var/log/mail.log to /var/log/mail.log.1
running postrotate script
0


Summary:

# logrotate -d /tmp/test.conf; echo $?
[..]
removing old log /var/log/mail.log.5.gz
error: error opening /var/log/mail.log.5.gz: No such file or directory

exitcode: 1

# logrotate -v /tmp/test.conf; echo $?
[..]
log /var/log/mail.log.5.gz doesn't exist -- won't try to dispose of it

exitcode: 0


1) The release of Ubuntu you are using, via 'lsb_release -rd' or System -> About Ubuntu
Description:	Ubuntu 12.04.3 LTS
Release:	12.04

2) The version of the package you are using, via 'apt-cache policy pkgname' or by checking in Software Center
logrotate:
  Installed: 3.7.8-6ubuntu5
  Candidate: 3.7.8-6ubuntu5

3) What you expected to happen
debug mode should not output an error and should have exitcode 0

4) What happened instead
debug mode prints an error and has exitcode 1

** Affects: logrotate (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to logrotate in Ubuntu.
https://bugs.launchpad.net/bugs/1320201

Title:
  behaviour in debug mode doesn't match real behaviour

Status in “logrotate” package in Ubuntu:
  New

Bug description:
  Situation: a single log file (no earlier rotates) and a logrotate
  status that says it is time to rotate.

  # ls -l /var/log/mail.log*
  -rw-r----- 1 syslog adm 287 May 16 11:27 /var/log/mail.log

  # cat /var/lib/logrotate/status 
  logrotate state -- version 2
  "/var/log/mail.log" 2012-3-31

  # cat /tmp/test.conf 
  /var/log/mail.log
  {
  	rotate 4
  	weekly
  	missingok
  	notifempty
  	compress
  	delaycompress
  	sharedscripts
  	postrotate
  		reload rsyslog >/dev/null 2>&1 || true
  	endscript
  }

  logrotate in debug mode will fail, because it simulates removing a
  non-existing mail.log.5.gz:

  # logrotate -d /tmp/test.conf; echo $?
  reading config file /tmp/test.conf
  reading config info for /var/log/mail.log

  
  Handling 1 logs

  rotating pattern: /var/log/mail.log
   weekly (4 rotations)
  empty log files are not rotated, old logs are removed
  considering log /var/log/mail.log
    log needs rotating
  rotating log /var/log/mail.log, log->rotateCount is 4
  dateext suffix '-20140516'
  glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
  previous log /var/log/mail.log.1 does not exist
  renaming /var/log/mail.log.4.gz to /var/log/mail.log.5.gz (rotatecount 4, logstart 1, i 4), 
  renaming /var/log/mail.log.3.gz to /var/log/mail.log.4.gz (rotatecount 4, logstart 1, i 3), 
  renaming /var/log/mail.log.2.gz to /var/log/mail.log.3.gz (rotatecount 4, logstart 1, i 2), 
  renaming /var/log/mail.log.1.gz to /var/log/mail.log.2.gz (rotatecount 4, logstart 1, i 1), 
  renaming /var/log/mail.log.0.gz to /var/log/mail.log.1.gz (rotatecount 4, logstart 1, i 0), 
  renaming /var/log/mail.log to /var/log/mail.log.1
  running postrotate script
  running script (multiple) with arg /var/log/mail.log
  : "
  		reload rsyslog >/dev/null 2>&1 || true
  "
  removing old log /var/log/mail.log.5.gz
  error: error opening /var/log/mail.log.5.gz: No such file or directory
  1

  
  logrotate's real behaviour handles this situation correctly:

  # logrotate -v /tmp/test.conf; echo $?
  reading config file /tmp/test.conf
  reading config info for /var/log/mail.log

  
  Handling 1 logs

  rotating pattern: /var/log/mail.log
   weekly (4 rotations)
  empty log files are not rotated, old logs are removed
  considering log /var/log/mail.log
    log needs rotating
  rotating log /var/log/mail.log, log->rotateCount is 4
  dateext suffix '-20140516'
  glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
  previous log /var/log/mail.log.1 does not exist
  renaming /var/log/mail.log.4.gz to /var/log/mail.log.5.gz (rotatecount 4, logstart 1, i 4), 
  old log /var/log/mail.log.4.gz does not exist
  renaming /var/log/mail.log.3.gz to /var/log/mail.log.4.gz (rotatecount 4, logstart 1, i 3), 
  old log /var/log/mail.log.3.gz does not exist
  renaming /var/log/mail.log.2.gz to /var/log/mail.log.3.gz (rotatecount 4, logstart 1, i 2), 
  old log /var/log/mail.log.2.gz does not exist
  renaming /var/log/mail.log.1.gz to /var/log/mail.log.2.gz (rotatecount 4, logstart 1, i 1), 
  old log /var/log/mail.log.1.gz does not exist
  renaming /var/log/mail.log.0.gz to /var/log/mail.log.1.gz (rotatecount 4, logstart 1, i 0), 
  old log /var/log/mail.log.0.gz does not exist
  log /var/log/mail.log.5.gz doesn't exist -- won't try to dispose of it
  renaming /var/log/mail.log to /var/log/mail.log.1
  running postrotate script
  0

  
  Summary:

  # logrotate -d /tmp/test.conf; echo $?
  [..]
  removing old log /var/log/mail.log.5.gz
  error: error opening /var/log/mail.log.5.gz: No such file or directory

  exitcode: 1

  # logrotate -v /tmp/test.conf; echo $?
  [..]
  log /var/log/mail.log.5.gz doesn't exist -- won't try to dispose of it

  exitcode: 0


  
  1) The release of Ubuntu you are using, via 'lsb_release -rd' or System -> About Ubuntu
  Description:	Ubuntu 12.04.3 LTS
  Release:	12.04

  2) The version of the package you are using, via 'apt-cache policy pkgname' or by checking in Software Center
  logrotate:
    Installed: 3.7.8-6ubuntu5
    Candidate: 3.7.8-6ubuntu5

  3) What you expected to happen
  debug mode should not output an error and should have exitcode 0

  4) What happened instead
  debug mode prints an error and has exitcode 1

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/logrotate/+bug/1320201/+subscriptions



More information about the foundations-bugs mailing list