From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id C90B11FF13F for ; Thu, 09 Apr 2026 15:27:20 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 113645A33; Thu, 9 Apr 2026 15:28:04 +0200 (CEST) From: Lukas Wagner To: pdm-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup 1/5] notifications: move spool directory to /var/lib/proxmox-backup/notifications/queue Date: Thu, 9 Apr 2026 15:27:17 +0200 Message-ID: <20260409132721.272178-2-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260409132721.272178-1-l.wagner@proxmox.com> References: <20260409132721.272178-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: 1775741180271 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.053 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [mod.rs] Message-ID-Hash: LEOIMZWPYKN43BIIJT2FZJL5ODJWQ7IO X-Message-ID-Hash: LEOIMZWPYKN43BIIJT2FZJL5ODJWQ7IO 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 Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: In anticipation of more notification-related data that might be stored soon (notification history, oauth tokens, etc.), we move the spool directory that is used to queue notifications that are sent by the proxy process to a separate subdirectory. We still read from the old directory, for the rare cases that there might still be any unsent notifications before the package is upgraded. Signed-off-by: Lukas Wagner --- src/server/notifications/mod.rs | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/server/notifications/mod.rs b/src/server/notifications/mod.rs index 95ff9ef18..15de5ccc5 100644 --- a/src/server/notifications/mod.rs +++ b/src/server/notifications/mod.rs @@ -18,7 +18,11 @@ use pbs_api_types::{ use proxmox_notify::endpoints::sendmail::{SendmailConfig, SendmailEndpoint}; use proxmox_notify::{Endpoint, Notification, Severity}; -const SPOOL_DIR: &str = concatcp!(pbs_buildcfg::PROXMOX_BACKUP_STATE_DIR, "/notifications"); +const SPOOL_DIR_OLD: &str = concatcp!(pbs_buildcfg::PROXMOX_BACKUP_STATE_DIR, "/notifications"); +const SPOOL_DIR: &str = concatcp!( + pbs_buildcfg::PROXMOX_BACKUP_STATE_DIR, + "/notifications/queue" +); mod template_data; @@ -43,14 +47,15 @@ pub fn create_spool_dir() -> Result<(), Error> { .owner(backup_user.uid) .group(backup_user.gid); - create_path(SPOOL_DIR, None, Some(opts))?; + create_path(SPOOL_DIR, Some(opts), Some(opts))?; Ok(()) } -async fn send_queued_notifications() -> Result<(), Error> { - let mut read_dir = tokio::fs::read_dir(SPOOL_DIR).await?; - - let mut notifications = Vec::new(); +async fn read_notifications_from_spool_dir( + notifications: &mut Vec, + path: &str, +) -> Result<(), Error> { + let mut read_dir = tokio::fs::read_dir(path).await?; while let Some(entry) = read_dir.next_entry().await? { let path = entry.path(); @@ -71,6 +76,19 @@ async fn send_queued_notifications() -> Result<(), Error> { } } + Ok(()) +} + +async fn send_queued_notifications() -> Result<(), Error> { + let mut notifications = Vec::new(); + + // Also read left-over notifications from the old directory -- we should be able to remove this + // pretty soon. + // FIXME: Remove this with the next minor update. + read_notifications_from_spool_dir(&mut notifications, SPOOL_DIR_OLD).await?; + + read_notifications_from_spool_dir(&mut notifications, SPOOL_DIR).await?; + if notifications.is_empty() { return Ok(()); } -- 2.47.3