proxmox-backup-proxy: clean up old tasks when the task log was rotated

we maybe have old tasks when the task list was rotated, so clean them up

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-10-07 14:03:37 +02:00 committed by Dietmar Maurer
parent de55fff226
commit 0e1edf19b1
1 changed files with 9 additions and 2 deletions

View File

@ -22,13 +22,13 @@ use proxmox::api::{RpcEnvironment, RpcEnvironmentType, UserInformation};
use proxmox::sys::linux::socket::set_tcp_keepalive; use proxmox::sys::linux::socket::set_tcp_keepalive;
use proxmox::tools::fs::CreateOptions; use proxmox::tools::fs::CreateOptions;
use pbs_tools::task_log; use pbs_tools::{task_log, task_warn};
use pbs_datastore::DataStore; use pbs_datastore::DataStore;
use proxmox_rrd::DST; use proxmox_rrd::DST;
use proxmox_rest_server::{ use proxmox_rest_server::{
rotate_task_log_archive, extract_cookie , AuthError, ApiConfig, RestServer, RestEnvironment, rotate_task_log_archive, extract_cookie , AuthError, ApiConfig, RestServer, RestEnvironment,
ServerAdapter, WorkerTask, ServerAdapter, WorkerTask, cleanup_old_tasks,
}; };
use proxmox_backup::{ use proxmox_backup::{
@ -827,6 +827,13 @@ async fn schedule_task_log_rotate() {
task_log!(worker, "API authentication log was not rotated"); task_log!(worker, "API authentication log was not rotated");
} }
if has_rotated {
task_log!(worker, "cleaning up old task logs");
if let Err(err) = cleanup_old_tasks(true) {
task_warn!(worker, "could not completely cleanup old tasks: {}", err);
}
}
Ok(()) Ok(())
}); });