From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id DEDCD1FF0C0 for ; Wed, 18 Nov 2026 10:49:48 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 782EE21BE3; Wed, 18 Nov 2026 10:45:06 +0100 (CET) From: Lukas Wagner To: pve-devel@lists.proxmox.com Subject: [PATCH pve-cluster v2 51/63] notify: send notifications via notification queue Date: Wed, 18 Nov 2026 10:43:35 +0100 Message-ID: <20261118094348.273646-52-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261118094348.273646-1-l.wagner@proxmox.com> References: <20261118094348.273646-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794995041504 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.190 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_CSS_A 0.1 Contains URL's A record listed in the Spamhaus CSS blocklist [139.162.176.150] Message-ID-Hash: JK4HAUXET4FZPFRUJWIAMX5E7O35LBVZ X-Message-ID-Hash: JK4HAUXET4FZPFRUJWIAMX5E7O35LBVZ X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Instead of reading the configuration and sending the notification directly, based on the targets and matchers defined in the config, use the new PVE::RS::Notify::enqueue function to write the notification to the notification queue. For cases where the notification configuration was explicitly provided by the caller (used only by 'legacy-sendmail' mode when sending backup job notifications), we add a simply check to switch over to the new semantics where only the specific sendmail endpoint config is provided, instead of a full notification config. If package version requirements are bumped correctly this should not strictly be needed, but this tiny fallback-mechanism does not really hurt, as the old `send` path will continue to exist anyway. Signed-off-by: Lukas Wagner --- src/PVE/Notify.pm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/PVE/Notify.pm b/src/PVE/Notify.pm index 89be6bc..5cfecf3 100644 --- a/src/PVE/Notify.pm +++ b/src/PVE/Notify.pm @@ -64,8 +64,22 @@ sub write_config { my $send_notification = sub { my ($severity, $template_name, $template_data, $fields, $config) = @_; - $config = read_config() if !defined($config); - $config->send($severity, $template_name, $template_data, $fields); + + my $recipient = undef; + + if (defined($config)) { + if (ref($config) eq 'PVE::RS::Notify') { + # Old style with explicitly provided config, call send directly. + $config->send($severity, $template_name, $template_data, $fields); + return; + } else { + # New style email-based recipient, set the recipient to the provided config + # and try to send via queue. + $recipient = $config; + } + } + + PVE::RS::Notify::enqueue($severity, $template_name, $template_data, $fields, $recipient); }; sub notify { -- 2.47.3