all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox 3/3] s3-client: extend provider quirks by delete objects via delete object
Date: Tue, 27 Jan 2026 13:27:11 +0100	[thread overview]
Message-ID: <20260127122712.505774-4-c.ebner@proxmox.com> (raw)
In-Reply-To: <20260127122712.505774-1-c.ebner@proxmox.com>

Provide a workaround for providers not implementing the delete objects
S3 API method.

If ProviderQuirks::DeleteObjectsViaDeleteObject is set,
S3Client::delete_objects() performs individual
S3Client::delete_object() calls on each provided object key instead
of deleting the keys via the deleteObjects API call.

This can also be used to reduce POST calls in favor of multiple
DELETE calls, which might be charged differently by some S3 object
store providers.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 proxmox-s3-client/src/api_types.rs |  2 ++
 proxmox-s3-client/src/client.rs    | 31 +++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/proxmox-s3-client/src/api_types.rs b/proxmox-s3-client/src/api_types.rs
index 93573fbd..b4fc24e0 100644
--- a/proxmox-s3-client/src/api_types.rs
+++ b/proxmox-s3-client/src/api_types.rs
@@ -87,6 +87,8 @@ pub const S3_BUCKET_NAME_SCHEMA: Schema = StringSchema::new("Bucket name for S3
 pub enum ProviderQuirks {
     /// Prvider does not support the If-None-Match http header
     SkipIfNoneMatchHeader,
+    /// Prvider does not support DeleteObjects API endpoint, use delete object calls instead
+    DeleteObjectsViaDeleteObject,
 }
 serde_plain::derive_display_from_serialize!(ProviderQuirks);
 serde_plain::derive_fromstr_from_deserialize!(ProviderQuirks);
diff --git a/proxmox-s3-client/src/client.rs b/proxmox-s3-client/src/client.rs
index 3d0af5d6..a6a3c5f9 100644
--- a/proxmox-s3-client/src/client.rs
+++ b/proxmox-s3-client/src/client.rs
@@ -29,7 +29,7 @@ use crate::aws_sign_v4::AWS_SIGN_V4_DATETIME_FORMAT;
 use crate::aws_sign_v4::{aws_sign_v4_signature, aws_sign_v4_uri_encode};
 use crate::object_key::S3ObjectKey;
 use crate::response_reader::{
-    CopyObjectResponse, DeleteObjectsResponse, DeletedObject, GetObjectResponse,
+    CopyObjectResponse, DeleteObjectError, DeleteObjectsResponse, DeletedObject, GetObjectResponse,
     HeadObjectResponse, ListBucketsResponse, ListObjectsV2Response, PutObjectResponse,
     ResponseReader,
 };
@@ -567,6 +567,35 @@ impl S3Client {
             return Ok(DeleteObjectsResponse::default());
         }
 
+        if self
+            .options
+            .provider_quirks
+            .contains(&ProviderQuirks::DeleteObjectsViaDeleteObject)
+        {
+            let mut response = DeleteObjectsResponse::default();
+            response.deleted = Some(Vec::with_capacity(object_keys.len()));
+
+            for object_key in object_keys {
+                match self.delete_object(object_key.clone()).await {
+                    Ok(deleted_object) => {
+                        let deleted = response.deleted.get_or_insert(Vec::new());
+                        deleted.push(deleted_object);
+                    }
+                    Err(err) => {
+                        let mut errors = response.error.get_or_insert(Vec::new());
+                        errors.push(DeleteObjectError {
+                            code: None,
+                            key: Some(object_key.clone()),
+                            message: Some(format!("{err}")),
+                            version_id: None,
+                        });
+                    }
+                }
+            }
+
+            return Ok(response);
+        }
+
         let mut body = String::from(r#"<Delete xmlns="http://s3.amazonaws.com/doc/2006-03-01/">"#);
         for object_key in object_keys {
             body.push_str("<Object><Key>");
-- 
2.47.3



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


  parent reply	other threads:[~2026-01-27 12:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27 12:27 [pbs-devel] [PATCH proxmox{, -backup} 0/4] fix #7078: Add quirk for providers not supporting deleteObjects Christian Ebner
2026-01-27 12:27 ` [pbs-devel] [PATCH proxmox 1/3] s3-client: factor out optional response header parsing Christian Ebner
2026-01-27 12:27 ` [pbs-devel] [PATCH proxmox 2/3] s3-client: parse and return headers for delete object response Christian Ebner
2026-01-27 12:27 ` Christian Ebner [this message]
2026-01-27 12:27 ` [pbs-devel] [PATCH proxmox-backup 1/1] fix #7078: ui: exponse DeleteObjects via DeleteObject provider quirk Christian Ebner

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=20260127122712.505774-4-c.ebner@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pbs-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal