[SERVER-62938] Log rotate for auditing does not work on startup Created: 24/Jan/22  Updated: 07/Feb/22  Resolved: 07/Feb/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Shreyas Kalyan Assignee: Erwin Pe
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-61699 Failure to rotate audit log on startu... Closed
Operating System: ALL
Sprint: Security 2022-02-21
Participants:

 Description   

Looking through logs for audit tasks on master and v5.2, specifically the test for log_rotate_startup.js, there are lots of messages saying "Log rotation initiated" immediately followed by "Unknown log type for rotate". We should make sure that the logs are rotating correctly on startup and fix the test log_rotate_startup to catch this and to ensure that future changes don't break this behavior.



 Comments   
Comment by Erwin Pe [ 07/Feb/22 ]

From the test logs, the "Unknown log type for rotate" error is only logged by the config server instances, which do not start with the --auditDestination=file option. Before this check was added by this commit for SERVER-61699 , the logv2::rotateLogs() function gets called with log type kAuditLogTag regardless of whether audit logging is enabled. Also, the log rotator callback with this log type only gets registered if audit logging is enabled and is destined to a file (see here). Since the config server has not enabled audit logging, the audit log rotator callback was never registered, and so the logv2::rotateLogs() function emits this error message when given the log type kAuditLogTag.

TL;DR: this issue has been fixed in SERVER-61699. Before that fix, errors from the very first audit log rotation (i.e. rotateAuditLog()), such as this one, were simply ignored.

Generated at Thu Feb 08 05:56:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.