From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/2] proxmox-backup-proxy: clean up old tasks when the task log was rotated
Date: Thu, 7 Oct 2021 14:03:37 +0200 [thread overview]
Message-ID: <20211007120337.3723803-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20211007120337.3723803-1-d.csapak@proxmox.com>
we maybe have old tasks when the task list was rotated, so clean them up
Signed-off-by: Dominik Csapak <d.csapak@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
next prev parent reply other threads:[~2021-10-07 12:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-07 12:03 [pbs-devel] [PATCH proxmox-backup 1/2] rest-server: add cleanup_old_tasks Dominik Csapak
2021-10-07 12:03 ` Dominik Csapak [this message]
2021-10-08 4:49 ` [pbs-devel] applied: [PATCH proxmox-backup 2/2] proxmox-backup-proxy: clean up old tasks when the task log was rotated Dietmar Maurer
2021-10-08 4:49 ` [pbs-devel] applied: [PATCH proxmox-backup 1/2] rest-server: add cleanup_old_tasks Dietmar Maurer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211007120337.3723803-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox