public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Lukas Wagner <l.wagner@proxmox.com>
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	[thread overview]
Message-ID: <20260409132721.272178-2-l.wagner@proxmox.com> (raw)
In-Reply-To: <20260409132721.272178-1-l.wagner@proxmox.com>

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 <l.wagner@proxmox.com>
---
 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<Notification>,
+    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





  reply	other threads:[~2026-04-09 13:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-09 13:27 [PATCH proxmox{-backup,-mail-forward} 0/5] forward mails through notification worker; PDM compatibility Lukas Wagner
2026-04-09 13:27 ` Lukas Wagner [this message]
2026-04-09 14:52   ` [PATCH proxmox-backup 1/5] notifications: move spool directory to /var/lib/proxmox-backup/notifications/queue Arthur Bied-Charreton
2026-04-09 13:27 ` [PATCH proxmox-backup 2/5] pull in 'mail-forwarder' feature for proxmox-notify Lukas Wagner
2026-04-09 14:54   ` Arthur Bied-Charreton
2026-04-09 13:27 ` [PATCH proxmox-mail-forward 3/5] forward using PBS' notification worker Lukas Wagner
2026-04-09 15:03   ` Arthur Bied-Charreton
2026-04-09 13:27 ` [PATCH proxmox-mail-forward 4/5] forward mails on PDM installations as well Lukas Wagner
2026-04-09 15:06   ` Arthur Bied-Charreton
2026-04-09 13:27 ` [PATCH proxmox-mail-forward 5/5] only ever forward for one product, favoring PVE over PBS over PDM Lukas Wagner
2026-04-09 15:15   ` Arthur Bied-Charreton

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=20260409132721.272178-2-l.wagner@proxmox.com \
    --to=l.wagner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=pdm-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal