* [pbs-devel] [PATCH proxmox{, -backup} 0/3] Always print workertask start and end logs to syslog
@ 2025-09-03 14:13 Gabriel Goller
2025-09-03 14:13 ` [pbs-devel] [PATCH proxmox 1/2] worker_task: always print the result message to the syslog Gabriel Goller
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Gabriel Goller @ 2025-09-03 14:13 UTC (permalink / raw)
To: pbs-devel
This series adds a few things:
* print a workertask start message to the syslog and the tasklog
* always print the result message to the syslog
* add the upid to the task's start and end messages
This allows us to see which tasks have been started and when regardless of the
tracing filtering and task result status.
proxmox:
Gabriel Goller (2):
worker_task: always print the result message to the syslog
worker_task: print worker starting message and upid
proxmox-rest-server/src/worker_task.rs | 32 ++++++++++++++++++++------
1 file changed, 25 insertions(+), 7 deletions(-)
proxmox-backup:
Gabriel Goller (1):
prune: add upid to workertask log_result function
src/api2/admin/datastore.rs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Summary over all repositories:
2 files changed, 28 insertions(+), 8 deletions(-)
--
Generated by git-murpp 0.8.0
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pbs-devel] [PATCH proxmox 1/2] worker_task: always print the result message to the syslog
2025-09-03 14:13 [pbs-devel] [PATCH proxmox{, -backup} 0/3] Always print workertask start and end logs to syslog Gabriel Goller
@ 2025-09-03 14:13 ` Gabriel Goller
2025-09-03 14:13 ` [pbs-devel] [PATCH proxmox 2/2] worker_task: print worker starting message and upid Gabriel Goller
2025-09-03 14:13 ` [pbs-devel] [PATCH proxmox-backup 1/1] prune: add upid to workertask log_result function Gabriel Goller
2 siblings, 0 replies; 4+ messages in thread
From: Gabriel Goller @ 2025-09-03 14:13 UTC (permalink / raw)
To: pbs-devel
When a worker-task ends it prints a result line. This line is written
directly to the tasklog file, because we want to bypass tracing (to
avoid this line getting filtered). Force this line into the syslog as
well by always printing it to stderr, which will end up in syslog. This
means that regardless of the task's result (failure or success) or the
tracing filtering, the last line will always be printed to syslog.
Suggested-by: Friedrich Weber <f.weber@proxmox.com>
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
proxmox-rest-server/src/worker_task.rs | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs
index a3a65add5ce8..6840938bdb2a 100644
--- a/proxmox-rest-server/src/worker_task.rs
+++ b/proxmox-rest-server/src/worker_task.rs
@@ -1026,9 +1026,7 @@ impl WorkerTask {
match LogContext::current() {
Some(context) => {
context.log_unfiltered(&state.result_text());
- if result.is_err() {
- eprintln!("{}", &state.result_text());
- }
+ eprintln!("{}", &state.result_text());
}
None => error!("error writing task result to the tasklog"),
}
--
2.47.2
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pbs-devel] [PATCH proxmox 2/2] worker_task: print worker starting message and upid
2025-09-03 14:13 [pbs-devel] [PATCH proxmox{, -backup} 0/3] Always print workertask start and end logs to syslog Gabriel Goller
2025-09-03 14:13 ` [pbs-devel] [PATCH proxmox 1/2] worker_task: always print the result message to the syslog Gabriel Goller
@ 2025-09-03 14:13 ` Gabriel Goller
2025-09-03 14:13 ` [pbs-devel] [PATCH proxmox-backup 1/1] prune: add upid to workertask log_result function Gabriel Goller
2 siblings, 0 replies; 4+ messages in thread
From: Gabriel Goller @ 2025-09-03 14:13 UTC (permalink / raw)
To: pbs-devel
In addition to forcing the task result (last message) to the tasklog
file and syslog, also force a start message to file and syslog. When
printing to syslog, also add the upid (in the tasklog the upid is
already visible in th window header or the status tab).
This allows us to always see the start and end log of a task in the
syslog and tasklog regardless of the task's result (failure or success)
and the tracing filtering.
Suggested-by: Friedrich Weber <f.weber@proxmox.com>
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
proxmox-rest-server/src/worker_task.rs | 30 +++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs
index 6840938bdb2a..e036c54f78dd 100644
--- a/proxmox-rest-server/src/worker_task.rs
+++ b/proxmox-rest-server/src/worker_task.rs
@@ -921,7 +921,7 @@ impl WorkerTask {
let res = setup.update_active_workers(Some(&upid));
if res.is_err() {
// needed to undo the insertion into WORKER_TASK_LIST above
- worker.log_result(&res);
+ worker.log_result(&res, &upid.to_string());
res?
}
@@ -942,11 +942,14 @@ impl WorkerTask {
{
let (worker, logger) = WorkerTask::new(worker_type, worker_id, auth_id, to_stdout)?;
let upid_str = worker.upid.to_string();
+ let inner_upid_str = upid_str.clone();
+ let inner_worker_type = worker_type.to_string();
let f = f(worker.clone());
tokio::spawn(LogContext::new(logger).scope(async move {
+ worker.log_start(&inner_upid_str, &inner_worker_type);
let result = f.await;
- worker.log_result(&result);
+ worker.log_result(&result, &inner_upid_str);
}));
Ok(upid_str)
@@ -965,12 +968,15 @@ impl WorkerTask {
{
let (worker, logger) = WorkerTask::new(worker_type, worker_id, auth_id, to_stdout)?;
let upid_str = worker.upid.to_string();
+ let inner_upid_str = upid_str.clone();
+ let inner_worker_type = worker_type.to_string();
let _child = std::thread::Builder::new()
.name(upid_str.clone())
.spawn(move || {
LogContext::new(logger).sync_scope(|| {
let worker1 = worker.clone();
+ worker1.log_start(&inner_upid_str, &inner_worker_type);
let result = match std::panic::catch_unwind(move || f(worker1)) {
Ok(r) => r,
@@ -985,7 +991,7 @@ impl WorkerTask {
},
};
- worker.log_result(&result);
+ worker.log_result(&result, &inner_upid_str);
});
});
@@ -1016,8 +1022,22 @@ impl WorkerTask {
}
}
+ /// Log task start message
+ pub fn log_start(&self, upid: &str, worker_type: &str) {
+ // Write the result manually to the workertask file. We don't want to filter or process
+ // this message by the logging system. This also guarantees the start message will be in
+ // the file, regardless of the logging level.
+ match LogContext::current() {
+ Some(context) => {
+ context.log_unfiltered(&format!("TASK: starting {worker_type} task"));
+ eprintln!("TASK: starting {worker_type} task - {upid}");
+ }
+ None => error!("error writing task start to the tasklog"),
+ }
+ }
+
/// Log task result, remove task from running list
- pub fn log_result(&self, result: &Result<(), Error>) {
+ pub fn log_result(&self, result: &Result<(), Error>, upid: &str) {
let state = self.create_state(result);
// Write the result manually to the workertask file. We don't want to filter or process
@@ -1026,7 +1046,7 @@ impl WorkerTask {
match LogContext::current() {
Some(context) => {
context.log_unfiltered(&state.result_text());
- eprintln!("{}", &state.result_text());
+ eprintln!("{} - {upid}", &state.result_text());
}
None => error!("error writing task result to the tasklog"),
}
--
2.47.2
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pbs-devel] [PATCH proxmox-backup 1/1] prune: add upid to workertask log_result function
2025-09-03 14:13 [pbs-devel] [PATCH proxmox{, -backup} 0/3] Always print workertask start and end logs to syslog Gabriel Goller
2025-09-03 14:13 ` [pbs-devel] [PATCH proxmox 1/2] worker_task: always print the result message to the syslog Gabriel Goller
2025-09-03 14:13 ` [pbs-devel] [PATCH proxmox 2/2] worker_task: print worker starting message and upid Gabriel Goller
@ 2025-09-03 14:13 ` Gabriel Goller
2 siblings, 0 replies; 4+ messages in thread
From: Gabriel Goller @ 2025-09-03 14:13 UTC (permalink / raw)
To: pbs-devel
The prune job builds the workertask from scratch (when no `use-task`
option is pased) so we need to pass the upid and print the starting
message manually.
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
src/api2/admin/datastore.rs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index a098aca8e114..3de28d2c6204 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -1002,8 +1002,10 @@ pub fn prune(
let (worker, logger) =
WorkerTask::new("prune", Some(worker_id), auth_id.to_string(), true)?;
let result = LogContext::new(logger).sync_scope(|| {
+ let upid = worker.upid().to_string();
+ worker.log_start(&upid, "prune");
let result = prune_group(worker.clone());
- worker.log_result(&Ok(()));
+ worker.log_result(&Ok(()), &upid);
result
});
Ok(json!(result))
--
2.47.2
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-09-03 14:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-03 14:13 [pbs-devel] [PATCH proxmox{, -backup} 0/3] Always print workertask start and end logs to syslog Gabriel Goller
2025-09-03 14:13 ` [pbs-devel] [PATCH proxmox 1/2] worker_task: always print the result message to the syslog Gabriel Goller
2025-09-03 14:13 ` [pbs-devel] [PATCH proxmox 2/2] worker_task: print worker starting message and upid Gabriel Goller
2025-09-03 14:13 ` [pbs-devel] [PATCH proxmox-backup 1/1] prune: add upid to workertask log_result function Gabriel Goller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.