From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pbs-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 468B51FF17F for <inbox@lore.proxmox.com>; Mon, 19 May 2025 13:48:06 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8FD5C8CFB; Mon, 19 May 2025 13:47:47 +0200 (CEST) From: Christian Ebner <c.ebner@proxmox.com> To: pbs-devel@lists.proxmox.com Date: Mon, 19 May 2025 13:46:24 +0200 Message-Id: <20250519114640.303640-24-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250519114640.303640-1-c.ebner@proxmox.com> References: <20250519114640.303640-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.031 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 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] [RFC proxmox-backup 23/39] verify: implement chunk verification for stores with s3 backend X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion <pbs-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/> List-Post: <mailto:pbs-devel@lists.proxmox.com> List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox Backup Server development discussion <pbs-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" <pbs-devel-bounces@lists.proxmox.com> For datastores backed by an S3 compatible object store, rather than reading the chunks to be verified from the local filesystem, fetch them via the s3 client from the configured bucket. Signed-off-by: Christian Ebner <c.ebner@proxmox.com> --- src/backup/verify.rs | 59 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/src/backup/verify.rs b/src/backup/verify.rs index a01ddcca3..2c28c6af5 100644 --- a/src/backup/verify.rs +++ b/src/backup/verify.rs @@ -5,6 +5,7 @@ use std::sync::{Arc, Mutex}; use std::time::Instant; use anyhow::{bail, Error}; +use hyper::body::HttpBody; use tracing::{error, info, warn}; use proxmox_worker_task::WorkerTaskContext; @@ -189,18 +190,52 @@ impl VerifyWorker { continue; // already verified or marked corrupt } - match self.datastore.load_chunk(&info.digest) { - Err(err) => { - self.corrupt_chunks.lock().unwrap().insert(info.digest); - error!("can't verify chunk, load failed - {err}"); - errors.fetch_add(1, Ordering::SeqCst); - Self::rename_corrupted_chunk(self.datastore.clone(), &info.digest); - } - Ok(chunk) => { - let size = info.size(); - read_bytes += chunk.raw_size(); - decoder_pool.send((chunk, info.digest, size))?; - decoded_bytes += size; + match &self.backend { + DatastoreBackend::Filesystem => match self.datastore.load_chunk(&info.digest) { + Err(err) => { + self.corrupt_chunks.lock().unwrap().insert(info.digest); + error!("can't verify chunk, load failed - {err}"); + errors.fetch_add(1, Ordering::SeqCst); + Self::rename_corrupted_chunk(self.datastore.clone(), &info.digest); + } + Ok(chunk) => { + let size = info.size(); + read_bytes += chunk.raw_size(); + decoder_pool.send((chunk, info.digest, size))?; + decoded_bytes += size; + } + }, + DatastoreBackend::S3(s3_client) => { + //TODO: How to avoid all these requests? Does the AWS api offer other means + // to verify the contents/integrity of objects? + match proxmox_async::runtime::block_on(s3_client.get_object(info.digest.into())) + { + Ok(Some(response)) => { + let bytes = + proxmox_async::runtime::block_on(response.content.collect())? + .to_bytes(); + let chunk = DataBlob::from_raw(bytes.to_vec())?; + let size = info.size(); + read_bytes += chunk.raw_size(); + decoder_pool.send((chunk, info.digest, size))?; + decoded_bytes += size; + } + Ok(None) => { + self.corrupt_chunks.lock().unwrap().insert(info.digest); + error!( + "can't verify missing chunk with digest {}", + hex::encode(info.digest) + ); + errors.fetch_add(1, Ordering::SeqCst); + } + Err(err) => { + self.corrupt_chunks.lock().unwrap().insert(info.digest); + error!("can't verify chunk, load failed - {err}"); + errors.fetch_add(1, Ordering::SeqCst); + //TODO: How to handle corrupt chunks for S3 store? + //Self::rename_corrupted_chunk(self.datastore.clone(), &info.digest); + } + } } } } -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel