From: Lukas Wagner <l.wagner@proxmox.com>
To: "Proxmox Backup Server development discussion"
<pbs-devel@lists.proxmox.com>,
"Fabian Grünbichler" <f.gruenbichler@proxmox.com>,
"Gabriel Goller" <g.goller@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup 14/33] server: notifications: send GC notifications via notification system
Date: Wed, 17 Apr 2024 16:26:04 +0200 [thread overview]
Message-ID: <352241d5-bc0d-487f-8ab5-9abad4a39ffe@proxmox.com> (raw)
In-Reply-To: <1713339434.lmgwlqq4ff.astroid@yuna.none>
On 2024-04-17 09:46, Fabian Grünbichler wrote:
> On April 16, 2024 2:13 pm, Lukas Wagner wrote:
>>
>>
>> On 2024-04-16 11:37, Gabriel Goller wrote:
>>> On Fri Apr 12, 2024 at 12:06 PM CEST, Lukas Wagner wrote:
>>>> diff --git a/src/server/gc_job.rs b/src/server/gc_job.rs
>>>> index 41375d72..ff5bdccf 100644
>>>> --- a/src/server/gc_job.rs
>>>> +++ b/src/server/gc_job.rs
>>>> @@ -19,8 +19,6 @@ pub fn do_garbage_collection_job(
>>>> ) -> Result<String, Error> {
>>>> let store = datastore.name().to_string();
>>>>
>>>> - let (email, notify) = crate::server::lookup_datastore_notify_settings(&store);
>>>> -
>>>> let worker_type = job.jobtype().to_string();
>>>> let upid_str = WorkerTask::new_thread(
>>>> &worker_type,
>>>> @@ -43,11 +41,9 @@ pub fn do_garbage_collection_job(
>>>> eprintln!("could not finish job state for {}: {err}", job.jobtype());
>>>> }
>>>>
>>>> - if let Some(email) = email {
>>>> - let gc_status = datastore.last_gc_status();
>>>> - if let Err(err) = send_gc_status(&email, notify, &store, &gc_status, &result) {
>>>> - eprintln!("send gc notification failed: {err}");
>>>> - }
>>>> + let gc_status = datastore.last_gc_status();
>>>> + if let Err(err) = send_gc_status(&store, &gc_status, &result) {
>>>> + eprintln!("send gc notification failed: {err}");
>>>
>>> I think we should use 'task_err!()' here. I know eprintln is used above,
>>> and technically works because we redirect stderr in the service setup
>>> but it's still slow and kinda the legacy method of printing task errors.
>>
>> I think the reason why the original code does not use task_log is because the
>> job is already marked as finished at that point:
>>
>> if let Err(err) = job.finish(status) {
>> eprintln!("could not finish job state for {}: {err}", job.jobtype());
>> }
>>
>> let gc_status = datastore.last_gc_status();
>> if let Err(err) = send_gc_status(&store, &gc_status, &result) {
>> eprintln!("send gc notification failed: {err}");
>> }
>>
>> Other jobs seem to follow the same pattern - use task_log! before, and eprintln/log::error!
>> after the job is finished.
>> A `task_log!` after the job is finished still seems to work, but I'm not sure if that
>> might lead to problems. What do you think?
>
> I don't think this is a problem per se - job.finish() just marks the job as
> finished in the job state, it's not related to the worker task
> finish/exit itself.
>
> since task_log (and friends) require the worker to still exist, and the
> last thing that happens when the worker fn returns its result is that
> result being logged via the same logging mechanism, this should be fine.
> but we might still want to switch the order around, so that a warning
> for notification failure actually gets counted?
>
> if it's such a common pattern to do job.start at the start, and
> job.finish near/at the end of a worker task, I wonder whether we
> couldn't handle that in a uniform fashion ;) then we might also not end
> up calling worker.create_state twice (once for job.finish, and once for
> worker.log_result as part of the worker exiting) with slightly different
> states..
>
Thanks a lot for your input!
I think I'll do the changes in a followup (if only to replace the eprintln!) - since
Gabriel's proxmox_log/tracing series is ripping out the task_log! macro any way.
--
- Lukas
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2024-04-17 14:26 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-12 10:05 [pbs-devel] [PATCH proxmox-backup 00/33] integrate " Lukas Wagner
2024-04-12 10:05 ` [pbs-devel] [PATCH proxmox-backup 01/33] pbs-config: add module for loading notification config Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 02/33] server: rename email_notifications module to notifications Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 03/33] notifications: allow sending notifications via proxmox_notify Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 04/33] buildsys: install templates for test notifications Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 05/33] pbs-config: acl: add /system/notifications as known ACL path Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 06/33] api: add endpoints for querying/testing notification targets Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 07/33] api: add endpoints for notification matchers Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 08/33] api: add endpoints for sendmail targets Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 09/33] api: add endpoints for smtp targets Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 10/33] api: add endpoints for gotify targets Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 11/33] api: add endpoints for querying known notification values/fields Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 12/33] api-types: api: datatore: add notification-mode parameter Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 13/33] api-types: api: tape: " Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 14/33] server: notifications: send GC notifications via notification system Lukas Wagner
2024-04-15 9:41 ` Gabriel Goller
2024-04-15 14:10 ` Lukas Wagner
2024-04-16 9:37 ` Gabriel Goller
2024-04-16 12:13 ` Lukas Wagner
2024-04-17 7:46 ` Fabian Grünbichler
2024-04-17 14:26 ` Lukas Wagner [this message]
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 15/33] server: notifications: send prune " Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 16/33] server: notifications: send verify " Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 17/33] server: notifications: send sync " Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 18/33] server: notifications: send update " Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 19/33] server: notifications: send acme " Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 20/33] server: notifications: send tape " Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 21/33] ui: add notification config panel Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 22/33] ui: tape backup job: add selector for notification-mode Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 23/33] ui: tape backup: add selector for 'notification-mode' Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 24/33] ui: tape restore: add 'notification-mode' parameter Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 25/33] ui: datastore options: " Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 26/33] ui: utils: add overrides for known notification metadata fields/values Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 27/33] ui: datastore edit: make new stores use notification system by default Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 28/33] ui: permissions paths: add /system/notifications to combobox Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 29/33] proxmox-backup-manager: add CLI for notification targets Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 30/33] proxmox-backup-manager: add CLI for notification matchers Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 31/33] proxmox-backup-manager: add CLI for gotify endpoints Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 32/33] proxmox-backup-manager: add CLI for sendmail endpoints Lukas Wagner
2024-04-12 10:06 ` [pbs-devel] [PATCH proxmox-backup 33/33] proxmox-backup-manager: add CLI for SMTP endpoints Lukas Wagner
2024-04-12 13:59 ` [pbs-devel] [PATCH proxmox-backup 00/33] integrate notification system Gabriel Goller
2024-04-12 14:09 ` Lukas Wagner
2024-04-17 8:22 ` Lukas Wagner
2024-04-17 10:26 ` Gabriel Goller
2024-04-17 10:26 ` Gabriel Goller
2024-04-17 12:31 ` Gabriel Goller
2024-04-17 14:38 ` Lukas Wagner
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=352241d5-bc0d-487f-8ab5-9abad4a39ffe@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=f.gruenbichler@proxmox.com \
--cc=g.goller@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