Cron logrotate job's exit code should be aligned with a logrotate's exit code

Bug #1428116 reported by Bogdan Dobrelya
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Fix Committed
Low
Bartłomiej Piotrowski

Bug Description

Original related issue https://bugs.launchpad.net/fuel/+bug/1427197

If logrotate failed, it should pass its exit code as the cron job exit code as well

Changed in fuel:
status: New → Confirmed
importance: Undecided → Low
milestone: none → 6.1
assignee: nobody → Fuel Library Team (fuel-library)
Changed in fuel:
assignee: Fuel Library Team (fuel-library) → Bartlomiej Piotrowski (bpiotrowski)
Revision history for this message
Bartłomiej Piotrowski (bpiotrowski) wrote :

The logrotate script seems fine in Ubuntu Trusty.

Revision history for this message
Bartłomiej Piotrowski (bpiotrowski) wrote :

(In more details: the last command of the script is logrotate itself, so it will exit with logrotate's exit code.)

Changed in fuel:
status: Confirmed → Invalid
Revision history for this message
Björn Pettersson (bjoernfan) wrote :

Hi people,

Sorry for a late reply, I never subscribed to this issue.

Bartlomiej, I disagree. Maybe you are looking in another place? Which I understand as this bug report is kind of thin on information. This is about the Fuel node, see below:

[root@fuel6 ~]# dockerctl shell rsyslog
[root@11f69530ccba ~]# cat /etc/cron.daily/logrotate
#!/bin/sh

/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
[root@11f69530ccba ~]# cat /etc/cron.hourly/logrotate
#!/bin/sh
# managed by puppet
#
# Due to bug existing, logrotate always returns 0. Use grep for detect errors:
# would return 1 (considered as normal result), if logrotate returns no errors, return 0, if any.
#/usr/sbin/logrotate /etc/logrotate.d/20-fuel.conf >/dev/null 2>&1
nice ionice -c3 /usr/sbin/logrotate /etc/logrotate.d/20-fuel*.conf >& /tmp/logrotate && grep -q error /tmp/logrotate

EXITVALUE=$?
if [ $EXITVALUE != 1 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE] (1 was expected)"
fi
exit 0

Unless this was recently changed, of course.

tags: added: logging low-hanging-fruit
Revision history for this message
Bartłomiej Piotrowski (bpiotrowski) wrote :

Ah, I'm sorry, I misunderstood the problem. Re-opening, I'll fix it.

Changed in fuel:
status: Invalid → Triaged
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to fuel-library (master)

Fix proposed to branch: master
Review: https://review.openstack.org/165872

Changed in fuel:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to fuel-library (master)

Reviewed: https://review.openstack.org/165872
Committed: https://git.openstack.org/cgit/stackforge/fuel-library/commit/?id=1fc729ed344f62ee9bb4295c7dcbe7afc2c43722
Submitter: Jenkins
Branch: master

commit 1fc729ed344f62ee9bb4295c7dcbe7afc2c43722
Author: Bartłomiej Piotrowski <email address hidden>
Date: Thu Mar 19 16:11:29 2015 +0100

    Ensure logrotate's cron scripts exit with logrotate return code

    Rewrite comment in logrotate-hourly to prevent possible confusion.

    Closes-Bug: 1428116
    Change-Id: Ie5fc660b5cc385f5e5015443f9a485ac0e7626d1

Changed in fuel:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.