Subject: bug#72527: Rottlog never exits cleanly

From: Simon Streit <[email-masked]>
Date: Thu, 08 Aug 2024 17:02:16 +0200

Hello!

On inspection of the default settings for Rot[t]log’s service, and
reading through /var/log/mcron.log, rottlog always exits with the
following error:

--8<---------------cut here---------------start------------->8---
2024-08-07 12:00:00 3408 /gnu/store/scligrs2fwpsy6jvffraa274k7ipbg81-rottlog-0.72.2/sbin/rottlog: running...
2024-08-07 12:00:01 3408 /gnu/store/scligrs2fwpsy6jvffraa274k7ipbg81-rottlog-0.72.2/sbin/rottlog: failed after 0.199s with: (misc-error #f unclean exit status ~S (1) #f)
--8<---------------cut here---------------end--------------->8---

Checking directly:

--8<---------------cut here---------------start------------->8---
root@host ~# /gnu/store/scligrs2fwpsy6jvffraa274k7ipbg81-rottlog-0.72.2/sbin/rottlog -v
read_custom: Config file 'custom' does not exist
read_daily: Config file 'daily' does not exist
check_last_rotate: Checking for week(ly) config file
check_last_rotate: Old date  : 1722810339
check_last_rotate: New date  : 1723125091
check_last_rotate: Next date : Thu 15 Aug 16:51:31 CEST 2024
check_last_rotate: Rotation not needed: 314752 < 604800
read_monthly: Config file 'monthly' does not exist
root@host ~# echo $?
1
--8<---------------cut here---------------end--------------->8---

To experiment a little, I add:

--8<---------------cut here---------------start------------->8---
(simple-service 'nginx-custom-rotations rottlog-service-type
                (list (log-rotation
                       (frequency 'custom)
                       (files '("/var/log/nginx/access.log"
                                "/var/log/nginx/error.log"))
                       (options '("storedir nginx
period 15")))))
(simple-service 'nginx-daily-rotations rottlog-service-type
                (list (log-rotation
                       (frequency 'daily)
                       (files '("/var/log/nginx/access.log"
                                "/var/log/nginx/error.log"))
                       (options '("storedir nginx")))))
(simple-service 'nginx-monthly-rotations rottlog-service-type
                (list (log-rotation
                       (frequency 'monthly)
                       (files '("/var/log/nginx/access.log"
                                "/var/log/nginx/error.log"))
                       (options '("storedir nginx")))))
--8<---------------cut here---------------end--------------->8---

Upon reconfiguration, I called “/gnu/store/...rottlog -v” again, and
voilà, it exits cleanly.

The current default is to only provide a weekly rotation.  Rottlog
expects a custom, daily, weekly and monthly file.  The documentation
upstream doesn't state this directly.  Providing empty files doesn't
help either, as it then errors out about syntax errors.

Would it make sense to be sure that a weekly file is enough, or all four
files are provided in a way?  The latter option sounds like slight over
engineering.  The default weekly rotation is enough for a base system.

I doubt it this is someone’s first concern to read through
/var/log/mcron.log and understand the error message on a new system.
The error message is there and it is not clear why at first sight.

Kind regards

-- 
Simon