canonical / mongodb-operator

Charmed solution for MongoDB
Apache License 2.0
12 stars 14 forks source link

Add log rotation with "logrotate" #409

Closed dmitry-ratushnyy closed 7 months ago

dmitry-ratushnyy commented 7 months ago

Issue

ISSUE-398 At the current moment Charmed MongoDB logs, can grow very fast, especially audit log. For example when a user imports data sets.

Solution

Support log rotation to avoid consuming too much space with log files. Log will be rotated if they grow bigger than 100M, the check for log files size will be performed every minute

Result of log rotation

Screenshot 2024-04-23 at 18 59 47
dmitry-ratushnyy commented 7 months ago

Looks good, thank you so much for your work here it is great and a big work on your end. I am very grateful for it.

There are a few comments, some nits and a bigger picture question (regarding sigkill). If we decide to address the bigger picture question later I won't have an issue merging.

But I do have a few other questions:

  1. does mongos write to its own log file? If so then we should do similar operations to what you have done here for mongod logs
  2. Is it possible to add an integration test for this, (maybe with copying over large data). We could add @pytest.mark.skip("Test imports big files, do not run on CI") to the top so it doesn't run on CI and take up big resources.

Looks good, thank you so much for your work here it is great and a big work on your end. I am very grateful for it.

There are a few comments, some nits and a bigger picture question (regarding sigkill). If we decide to address the bigger picture question later I won't have an issue merging.

But I do have a few other questions:

  1. does mongos write to its own log file? If so then we should do similar operations to what you have done here for mongod logs

yes according to docs we need to sent same signal to mongos but I think we can \ should do it in a separate PR