[go: up one dir, main page]

Tezt/Cloud: add logrotate

Adds logrotate

Logrotate allows to rotate and compress logs with a defined frequency or if they grow until a certain size. see man logrotate

This MR uses it to rotate the tezt-cloud main log, for example, /tmp/log if one of this criteria is met:

  • everyday (daily)
  • if they grew larger than 200MB

It also limits the rotations to 300, so the max occupied space would be lower than 60G (if they do not grew up far larger than 200M in the chronos time interval). I think it should prevent the VM we use to crash (disk is 200G).

About the logrotate behavior expected by this MR

  • first, chronos triggers logrotate every 4 hours
  • if logrotate sees that the logfile is larger than 200M, it will be rotated
  • if logrotate sees that the logfile is aged more than 24h ago (daily), it will be rotated

TODO:

  • fix the constants as defined
  • basic testing in proxy
  • confirm working in proxy mode (localhost and remote are not affected)

Note that logrotates must run as root, but does not like its config file or logfiles owned by root.

It is possible to test by using a smaller max size:

❯ git diff | cat
diff --git a/tezt/lib_cloud/logrotate.ml b/tezt/lib_cloud/logrotate.ml
index 886612fa5b7..08a05a22fe1 100644
--- a/tezt/lib_cloud/logrotate.ml
+++ b/tezt/lib_cloud/logrotate.ml
@@ -24,7 +24,7 @@ let write_config ~name ~target_file agent =
   copytruncate
   missingok
   notifempty
-  maxsize 200M
+  maxsize 1024
   rotate 300
   su root root
 }

Summary by CodeRabbit

  • New Features
    • Introduced a configurable log rotation option to control the maximum number of retained log files, with a default limit when logging is enabled and the ability to disable rotation entirely.
    • Added scheduled tasks to regularly perform log rotation in container environments, ensuring efficient log management.
    • Updated the container setup to include necessary support for log rotation.
Edited by Guillaume B

Merge request reports

Loading