rest-server: add option to rotate task logs by 'max_days' instead of 'max_files'

and use it with the configurable: 'task_log_max_days' of the node config

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak
2022-03-28 09:54:19 +02:00
committed by Thomas Lamprecht
parent eb419c5267
commit 416194d799
2 changed files with 56 additions and 3 deletions

View File

@ -847,6 +847,11 @@ async fn schedule_task_log_rotate() {
let max_size = 512 * 1024 - 1; // an entry has ~ 100b, so > 5000 entries/file
let max_files = 20; // times twenty files gives > 100000 task entries
let max_days = proxmox_backup::config::node::config()
.map(|(cfg, _)| cfg.task_log_max_days)
.ok()
.flatten();
let user = pbs_config::backup_user()?;
let options = proxmox_sys::fs::CreateOptions::new()
.owner(user.uid)
@ -856,6 +861,7 @@ async fn schedule_task_log_rotate() {
max_size,
true,
Some(max_files),
max_days,
Some(options.clone()),
)?;