rsyslog client postrotate script contains invalid command

Bug #1699875 reported by Chris Martin
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack-Ansible
Fix Released
High
Jean-Philippe Evrard

Bug Description

Both 14 (Newton) and 15 (Ocata) tags

From rsyslog_client/defaults/main.yml:
```
rsyslog_client_log_rotate_scripts:
  - name: postrotate
    content: "restart rsyslog 2>&1 || true"
```

This gets deployed as the following in logrotate files, e.g. /etc/logrotate.d/lxc_log_rotate:
```
/var/log/lxc/lxc-jet01_nova_conductor_container-ff747553.log
[...22 more logfiles...]
{
        copytruncate
        weekly
        missingok
        rotate 14
        compress
        dateext
        maxage 60
        notifempty
        nocreate
        postrotate
            restart rsyslog 2>&1 || true
        endscript
}
```

Unfortunately, `restart` is an upstart-ism and doesn't exist in the systemd world of Ubuntu 16.04, so this doesn't actually restart the rsyslog service.

It appears that now with Ocata, logrotate scripts are now also deployed to hosts (not just containers), to rotate the logfiles for each LXC. My hosts email me the contents of stderr from anything run by cron, so now this shows up in my email:

```
/etc/cron.daily/logrotate:
logrotate_script: 2: logrotate_script: restart: not found
[...22 more identical lines...]
```

I tried changing the postrotate script to `systemctl restart rsyslog 2>&1 || true`. This doesn't cause an error which results in an email, but it also doesn't actually restart the rsyslog service, and I don't know why. Maybe it's a file permissions issue, or something with selinux?

Revision history for this message
Jean-Philippe Evrard (jean-philippe-evrard) wrote :

We should be templating depending on the ansible_service_mgr: if "upstart", include this rule, if systemd, do something different.

Changed in openstack-ansible:
status: New → Confirmed
tags: added: low-hanging-fruit
Changed in openstack-ansible:
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-ansible-rsyslog_client (master)

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

Changed in openstack-ansible:
assignee: nobody → Jean-Philippe Evrard (jean-philippe-evrard)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-ansible-rsyslog_client (master)

Reviewed: https://review.openstack.org/494438
Committed: https://git.openstack.org/cgit/openstack/openstack-ansible-rsyslog_client/commit/?id=7b2cd66e972e52e3e3acd0916badd41324d0f43d
Submitter: Jenkins
Branch: master

commit 7b2cd66e972e52e3e3acd0916badd41324d0f43d
Author: Jean-Philippe Evrard <email address hidden>
Date: Thu Aug 17 08:35:53 2017 +0000

    Test postrotate works

    We should:
    - Not check what we do not set (kern.log and auth.log are already
    defined in rsyslog file, which we do not template). These two
    files would trigger an issue if both are in the same logrotate
    configuration.
    - Check that the rotation works, by forcing a rotation, and seeing
    that the new files are empty.

    Change-Id: I08357260e45919d9e71586cac6b9ce413adffc22
    Closes-Bug: 1699875
    Closes-Bug: 1709291

Changed in openstack-ansible:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-ansible-rsyslog_client (stable/pike)

Fix proposed to branch: stable/pike
Review: https://review.openstack.org/502413

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-ansible-rsyslog_client (stable/pike)

Reviewed: https://review.openstack.org/502413
Committed: https://git.openstack.org/cgit/openstack/openstack-ansible-rsyslog_client/commit/?id=a78e428e5d550c383bb0d1970c48c634beba4c06
Submitter: Jenkins
Branch: stable/pike

commit a78e428e5d550c383bb0d1970c48c634beba4c06
Author: Jean-Philippe Evrard <email address hidden>
Date: Thu Aug 17 08:35:53 2017 +0000

    Fix postrotate

    Combined backport of:
    - https://review.openstack.org/#/c/494438/
    - https://review.openstack.org/#/c/502252/

    Change-Id: I08357260e45919d9e71586cac6b9ce413adffc22
    Closes-Bug: #1699875
    Closes-Bug: #1709291
    Closes-Bug: #1716138

tags: added: in-stable-pike
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-ansible-rsyslog_client (stable/ocata)

Fix proposed to branch: stable/ocata
Review: https://review.openstack.org/514350

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-ansible-rsyslog_client (stable/newton)

Fix proposed to branch: stable/newton
Review: https://review.openstack.org/514357

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-ansible-rsyslog_client (stable/newton)

Reviewed: https://review.openstack.org/514357
Committed: https://git.openstack.org/cgit/openstack/openstack-ansible-rsyslog_client/commit/?id=69d69c5100dbdbe83fa85c5a94eb15fdfbfb1198
Submitter: Zuul
Branch: stable/newton

commit 69d69c5100dbdbe83fa85c5a94eb15fdfbfb1198
Author: Jean-Philippe Evrard <email address hidden>
Date: Thu Aug 17 08:35:53 2017 +0000

    Fix postrotate

    Adjustment of the restart command for Xenial and Trusty.

    Combined backport of:
    - https://review.openstack.org/#/c/494438/
    - https://review.openstack.org/#/c/502252/

    Change-Id: I08357260e45919d9e71586cac6b9ce413adffc22
    Closes-Bug: #1699875
    Closes-Bug: #1709291
    Closes-Bug: #1716138

tags: added: in-stable-newton
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/openstack-ansible-rsyslog_client 17.0.0.0b1

This issue was fixed in the openstack/openstack-ansible-rsyslog_client 17.0.0.0b1 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/openstack-ansible-rsyslog_client 16.0.2

This issue was fixed in the openstack/openstack-ansible-rsyslog_client 16.0.2 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/openstack-ansible-rsyslog_client 15.1.12

This issue was fixed in the openstack/openstack-ansible-rsyslog_client 15.1.12 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/openstack-ansible-rsyslog_client 14.2.12

This issue was fixed in the openstack/openstack-ansible-rsyslog_client 14.2.12 release.

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.