The logrotate service (at least on a monolith) fails to start with:
Apr 02 09:00:01 sprite logrotate[5747]: error: monolith:3 duplicate log entry for /home/cchq/www/monolith/log/commcare-hq.gunicorn.log
Apr 02 09:00:01 sprite logrotate[5747]: error: found error in file monolith, skipping
Apr 02 09:00:01 sprite systemd[1]: logrotate.service: Main process exited, code=exited, status=1/FAILURE
The issue is that in /etc/logrotate.d/monolith the glob "/home/cchq/www/monolith/log/*.log" matches commcare-hq.gunicorn.log, which is already matched in /etc/logrotate.d/commcare-hq-gunicorn.
Logrotate 3.21.0 introduced the option ignoreduplicates, which, if added in /etc/logrotate.d/commcare-hq-gunicorn, would resolve the issue provided that monolith ($environment) is alphabetically after commcare-hq-unicorn.
Either way, Ubuntu Jammy is on logrotate 3.19.0 so this doesn't help for the current release.
Possible fixes:
-
Quick & dirty: remove the commcare-hq-gunicorn logrotate config, so that commcare-hq.gunicorn.log is matched by the *.log glob; however note that it probably needs its copytruncate option
-
Quick: move the commcare-hq.gunicorn.log elsewhere, for instance to a subdirectory of the log directory
-
Clean: replace the *.log glob in the $environment logrotate config by the list of actual expected log file names; this is what I see:
"/home/cchq/www/${environment}/log/celery*.log"
"/home/cchq/www/${environment}/log/django.log"
"/home/cchq/www/${environment}/log/formplayer-spring.log"
"/home/cchq/www/${environment}/log/handle_*.log"
"/home/cchq/www/${environment}/log/${environment}*.log"
"/home/cchq/www/${environment}/log/pillowtop-*.log"
"/home/cchq/www/${environment}/log/queue_schedule_instances.log"
"/home/cchq/www/${environment}/log/run_*.log"
"/home/cchq/www/${environment}/log/${branch?}-*.log" # looks like branch prefix?
-
Proper: give each component its own logrotate config, matching its own log file pattern or, if that pattern is unpredictable, its own log subdirectory, so that a plain subdir/*.log will work for it.
The logrotate service (at least on a monolith) fails to start with:
The issue is that in
/etc/logrotate.d/monoliththe glob"/home/cchq/www/monolith/log/*.log"matchescommcare-hq.gunicorn.log, which is already matched in/etc/logrotate.d/commcare-hq-gunicorn.Logrotate 3.21.0 introduced the option
ignoreduplicates, which, if added in/etc/logrotate.d/commcare-hq-gunicorn, would resolve the issue provided thatmonolith ($environment)is alphabetically aftercommcare-hq-unicorn.Either way, Ubuntu Jammy is on logrotate 3.19.0 so this doesn't help for the current release.
Possible fixes:
Quick & dirty: remove the
commcare-hq-gunicornlogrotate config, so thatcommcare-hq.gunicorn.logis matched by the*.logglob; however note that it probably needs itscopytruncateoptionQuick: move the commcare-hq.gunicorn.log elsewhere, for instance to a subdirectory of the log directory
Clean: replace the
*.logglob in the$environmentlogrotate config by the list of actual expected log file names; this is what I see:Proper: give each component its own logrotate config, matching its own log file pattern or, if that pattern is unpredictable, its own log subdirectory, so that a plain
subdir/*.logwill work for it.