From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id E5AF61FF185 for ; Mon, 23 Jun 2025 16:13:12 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8B94E14177; Mon, 23 Jun 2025 16:13:43 +0200 (CEST) From: Lukas Wagner To: pbs-devel@lists.proxmox.com Date: Mon, 23 Jun 2025 16:13:08 +0200 Message-Id: <20250623141315.288681-4-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250623141315.288681-1-l.wagner@proxmox.com> References: <20250623141315.288681-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.018 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 Subject: [pbs-devel] [PATCH proxmox-backup 2/9] cli: manager: add 'migrate-config default-notification-mode' command X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" This one migrates any datastore or tape backup job that relied on the old default (legacy-sendmail) to an explicit setting of legacy-sendmail. This allows us the change the default without changing behavior for anybody. This new command is intended to be called by d/postinst on upgrade to the package version which introduces the new default value for 'notification-mode'. Signed-off-by: Lukas Wagner --- .../proxmox_backup_manager/migrate_config.rs | 77 ++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/src/bin/proxmox_backup_manager/migrate_config.rs b/src/bin/proxmox_backup_manager/migrate_config.rs index 214c8d71..9897218a 100644 --- a/src/bin/proxmox_backup_manager/migrate_config.rs +++ b/src/bin/proxmox_backup_manager/migrate_config.rs @@ -1,13 +1,20 @@ use anyhow::{bail, Error}; use serde::Deserialize; -use pbs_api_types::{DataStoreConfig, PruneJobConfig, PruneJobOptions}; +use pbs_api_types::{ + DataStoreConfig, NotificationMode, PruneJobConfig, PruneJobOptions, TapeBackupJobConfig, +}; use pbs_config::prune; /// Handle a 'migrate-config' command. pub fn handle_command(command: &str) -> Result<(), Error> { match command { - "update-to-prune-jobs-config" => return update_to_prune_jobs_config(), + "update-to-prune-jobs-config" => update_to_prune_jobs_config(), + "default-notification-mode" => { + migrate_tape_job_notification_mode()?; + migrate_datastore_notification_mode_default()?; + Ok(()) + } _ => bail!("invalid fixup command: {command}"), } } @@ -96,3 +103,69 @@ pub(crate) fn update_to_prune_jobs_config() -> Result<(), Error> { Ok(()) } + +/// Explicitly set 'notification-mode' to 'legacy-sendmail' for any datastore which +/// relied on the previous default of 'legacy-sendmail'. +/// +/// This allows us to change the default to 'notification-system' without any noticeable +/// change in behavior. +fn migrate_datastore_notification_mode_default() -> Result<(), Error> { + let _lock = pbs_config::datastore::lock_config()?; + + let (mut datastore_config, _digest) = pbs_config::datastore::config()?; + + for (store, entry) in datastore_config.sections.iter_mut() { + let mut config = match DataStoreConfig::deserialize(&entry.1) { + Ok(c) => c, + Err(err) => { + eprintln!("failed to parse config of store {store}: {err}"); + continue; + } + }; + + if config.notification_mode.is_none() { + config.notification_mode = Some(NotificationMode::LegacySendmail); + eprintln!("setting notification-mode of datastore '{store}' to 'legacy-sendmail' to presere previous default behavior."); + } + + entry.1 = serde_json::to_value(config)?; + } + + pbs_config::datastore::save_config(&datastore_config)?; + + Ok(()) +} + +/// Explicitly set 'notification-mode' to 'legacy-sendmail' for any tape backup job which +/// relied on the previous default of 'legacy-sendmail'. +/// +/// This allows us to change the default to 'notification-system' without any noticeable +/// change in behavior. +fn migrate_tape_job_notification_mode() -> Result<(), Error> { + let _lock = pbs_config::tape_job::lock()?; + + let (mut tapejob_config, _digest) = pbs_config::tape_job::config()?; + + for (job_id, entry) in tapejob_config.sections.iter_mut() { + let mut config = match TapeBackupJobConfig::deserialize(&entry.1) { + Ok(c) => c, + Err(err) => { + eprintln!("failed to parse config of tape-backup job {job_id}: {err}"); + continue; + } + }; + + if config.setup.notification_mode.is_none() { + config.setup.notification_mode = Some(NotificationMode::LegacySendmail); + eprintln!( + "setting notification-mode of tape backup job '{job_id}' to 'legacy-sendmail' to preserve previous default behavior." + ); + } + + entry.1 = serde_json::to_value(config)?; + } + + pbs_config::tape_job::save_config(&tapejob_config)?; + + Ok(()) +} -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel