[pbs-devel] [PATCH proxmox-backup 2/2] proxmox-backup-proxy: clean up old tasks when the task log was rotated
Dominik Csapak
d.csapak at proxmox.com
Thu Oct 7 14:03:37 CEST 2021
we maybe have old tasks when the task list was rotated, so clean them up
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
if we want to be *really* conservative with that call, we can modify the
rotate call so that it returns the info if we deleted a log file and
only call it then, but in my tests deleting thousands of files did not
even take a second (on a spinner)
src/bin/proxmox-backup-proxy.rs | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index 9199ebae..4c879483 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -22,13 +22,13 @@ use proxmox::api::{RpcEnvironment, RpcEnvironmentType, UserInformation};
use proxmox::sys::linux::socket::set_tcp_keepalive;
use proxmox::tools::fs::CreateOptions;
-use pbs_tools::task_log;
+use pbs_tools::{task_log, task_warn};
use pbs_datastore::DataStore;
use proxmox_rrd::DST;
use proxmox_rest_server::{
rotate_task_log_archive, extract_cookie , AuthError, ApiConfig, RestServer, RestEnvironment,
- ServerAdapter, WorkerTask,
+ ServerAdapter, WorkerTask, cleanup_old_tasks,
};
use proxmox_backup::{
@@ -827,6 +827,13 @@ async fn schedule_task_log_rotate() {
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(())
});
--
2.30.2
More information about the pbs-devel
mailing list