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 309B91FF183 for ; Wed, 30 Jul 2025 17:22:00 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 53FEF130D8; Wed, 30 Jul 2025 17:23:25 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Wed, 30 Jul 2025 17:23:03 +0200 Message-ID: <20250730152303.729778-1-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1753888990586 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.043 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. [lib.rs, datastore.rs] Subject: [pbs-devel] [PATCH proxmox-backup] datastore: destroy: delete s3 in-use marker unconditionally 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" Currently, the in-use marker object for datastores backed by s3 backend is only removed together with the data when all data is requested to be removed. It the data should be preserved, the in-use marker should however also be removed, allowing to reuse the datastore on the same or a different host without force overwriting the marker. Therefore, unconditionally clear the in-use marker from the S3 object store. In order to use the predefined marker filename constant move it so it can be used during destruction as well. Suggested-by: Lukas Wagner Signed-off-by: Christian Ebner --- pbs-datastore/src/datastore.rs | 11 +++++++++++ pbs-datastore/src/lib.rs | 2 +- src/api2/config/datastore.rs | 6 +++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs index 3e53a670b..57a90971a 100644 --- a/pbs-datastore/src/datastore.rs +++ b/pbs-datastore/src/datastore.rs @@ -53,6 +53,8 @@ static DATASTORE_MAP: LazyLock>>> = pub const GROUP_NOTES_FILE_NAME: &str = "notes"; /// Filename to store backup group owner pub const GROUP_OWNER_FILE_NAME: &str = "owner"; +/// Filename for in-use marker stored on S3 object store backend +pub const S3_DATASTORE_IN_USE_MARKER: &str = ".in-use"; const NAMESPACE_MARKER_FILENAME: &str = ".namespace"; /// checks if auth_id is owner, or, if owner is a token, if @@ -2160,6 +2162,15 @@ impl DataStore { if ok { remove(".chunks", &mut ok); } + } else if let (_backend, Some(s3_client)) = + Self::s3_client_and_backend_from_datastore_config(&datastore_config)? + { + + // Only delete in-use marker so datastore can be re-imported + let object_key = S3ObjectKey::try_from(S3_DATASTORE_IN_USE_MARKER) + .context("failed to generate in-use marker object key")?; + proxmox_async::runtime::block_on(s3_client.delete_object(object_key)) + .context("failed to delete in-use marker")?; } // now the config diff --git a/pbs-datastore/src/lib.rs b/pbs-datastore/src/lib.rs index b9eb035c2..849078a8f 100644 --- a/pbs-datastore/src/lib.rs +++ b/pbs-datastore/src/lib.rs @@ -204,7 +204,7 @@ pub use store_progress::StoreProgress; mod datastore; pub use datastore::{ check_backup_owner, ensure_datastore_is_mounted, get_datastore_mount_status, DataStore, - DatastoreBackend, + DatastoreBackend, S3_DATASTORE_IN_USE_MARKER, }; mod hierarchy; diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs index 1b56fd276..14532e5ec 100644 --- a/src/api2/config/datastore.rs +++ b/src/api2/config/datastore.rs @@ -32,15 +32,15 @@ use crate::api2::config::tape_backup_job::{delete_tape_backup_job, list_tape_bac use crate::api2::config::verify::delete_verification_job; use pbs_config::CachedUserInfo; -use pbs_datastore::{get_datastore_mount_status, DataStore, DatastoreBackend}; +use pbs_datastore::{ + get_datastore_mount_status, DataStore, DatastoreBackend, S3_DATASTORE_IN_USE_MARKER, +}; use proxmox_rest_server::WorkerTask; use proxmox_s3_client::S3ObjectKey; use crate::server::jobstate; use crate::tools::disks::unmount_by_mountpoint; -const S3_DATASTORE_IN_USE_MARKER: &str = ".in-use"; - #[derive(Default, serde::Deserialize, serde::Serialize)] #[serde(rename_all = "kebab-case")] struct InUseContent { -- 2.47.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel