From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox v2 2/2] s3 client: extend client options by feature list
Date: Tue, 29 Jul 2025 10:17:47 +0200 [thread overview]
Message-ID: <20250729081750.203736-3-c.ebner@proxmox.com> (raw)
In-Reply-To: <20250729081750.203736-1-c.ebner@proxmox.com>
Adds a feature list to the s3 client options, which allows to define
a set of provider specific implementation features or limitations to
be used by the client.
As a first limitation, the SkipIfNoneMatchHeader is added for
provider not accepting and implementing this headers functionality.
Defines also an associated helper function on S3ClientOptions to map
a given provider quirk to a feature list.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
changes since version 1:
- use feature list instead of provider for s3 client options, adding
flexibility for further extension
- add helper to map from provider quirk to feature list
- set If-None-Match header based on feature instead of provider quirk
proxmox-s3-client/examples/s3_client.rs | 1 +
proxmox-s3-client/src/api_types.rs | 11 +++++++++++
proxmox-s3-client/src/client.rs | 26 +++++++++++++++++++++++--
3 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/proxmox-s3-client/examples/s3_client.rs b/proxmox-s3-client/examples/s3_client.rs
index 1cbb3939..21b0e9ce 100644
--- a/proxmox-s3-client/examples/s3_client.rs
+++ b/proxmox-s3-client/examples/s3_client.rs
@@ -38,6 +38,7 @@ async fn run() -> Result<(), anyhow::Error> {
// `openssl s_client -connect testbucket.s3.pve-c1.local:7480 < /dev/null | openssl x509 -fingerprint -sha256 -noout`
fingerprint: Some("<s3-api-fingerprint>".to_string()),
put_rate_limit: None,
+ features: Vec::new(),
};
// Creating a client instance and connect to api endpoint
diff --git a/proxmox-s3-client/src/api_types.rs b/proxmox-s3-client/src/api_types.rs
index 7d1ad24e..a87e0804 100644
--- a/proxmox-s3-client/src/api_types.rs
+++ b/proxmox-s3-client/src/api_types.rs
@@ -211,3 +211,14 @@ pub struct S3ClientConfigWithoutSecret {
#[serde(flatten)]
pub config: S3ClientConfig,
}
+
+#[api]
+#[derive(Copy, Clone, Deserialize, Serialize, PartialEq, Eq)]
+#[serde(rename_all = "kebab-case")]
+/// Provider specific implementation feature or limitation.
+pub enum S3ClientFeature {
+ /// If-None-Match http header not implemented and not accepted.
+ SkipIfNoneMatchHeader,
+}
+serde_plain::derive_display_from_serialize!(S3ClientFeature);
+serde_plain::derive_fromstr_from_deserialize!(S3ClientFeature);
diff --git a/proxmox-s3-client/src/client.rs b/proxmox-s3-client/src/client.rs
index 3a981bf4..ce57722a 100644
--- a/proxmox-s3-client/src/client.rs
+++ b/proxmox-s3-client/src/client.rs
@@ -22,7 +22,7 @@ use proxmox_http::client::HttpsConnector;
use proxmox_http::{Body, RateLimit, RateLimiter};
use proxmox_schema::api_types::CERT_FINGERPRINT_SHA256_SCHEMA;
-use crate::api_types::S3ClientConfig;
+use crate::api_types::{ProviderQuirks, S3ClientConfig, S3ClientFeature};
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;
@@ -69,6 +69,8 @@ pub struct S3ClientOptions {
pub fingerprint: Option<String>,
/// Rate limit for put requests given as #reqest/s.
pub put_rate_limit: Option<u64>,
+ /// Provider implementation specific features and limitations
+ pub features: Vec<S3ClientFeature>,
}
impl S3ClientOptions {
@@ -90,6 +92,18 @@ impl S3ClientOptions {
access_key: config.access_key,
secret_key,
put_rate_limit: config.put_rate_limit,
+ features: Self::map_provider_quirks_to_features(config.provider_quirks),
+ }
+ }
+
+ fn map_provider_quirks_to_features(
+ provider_quirks: Option<ProviderQuirks>,
+ ) -> Vec<S3ClientFeature> {
+ match provider_quirks {
+ Some(ProviderQuirks::Backblaze) | Some(ProviderQuirks::Infomaniak) => {
+ vec![S3ClientFeature::SkipIfNoneMatchHeader]
+ }
+ _ => Vec::new(),
}
}
}
@@ -393,7 +407,15 @@ impl S3Client {
.header(header::CONTENT_TYPE, "binary/octet");
if !replace {
- request = request.header(header::IF_NONE_MATCH, "*");
+ // Some providers not implement this and fails with error if the header is set,
+ // see https://forum.proxmox.com/threads/168834/post-786278
+ if !self
+ .options
+ .features
+ .contains(&S3ClientFeature::SkipIfNoneMatchHeader)
+ {
+ request = request.header(header::IF_NONE_MATCH, "*");
+ }
}
let request = request.body(object_data)?;
--
2.47.2
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2025-07-29 8:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 8:17 [pbs-devel] [PATCH proxmox{, -backup} v2 0/4] s3: extend config by provider-quirks and " Christian Ebner
2025-07-29 8:17 ` [pbs-devel] [PATCH proxmox v2 1/2] s3 client: api types: extend client config by optional provider quirks Christian Ebner
2025-07-29 8:17 ` Christian Ebner [this message]
2025-07-29 8:17 ` [pbs-devel] [PATCH proxmox-backup v2 1/2] api: s3 config: allow to update or delete endpoint quirks Christian Ebner
2025-07-29 8:17 ` [pbs-devel] [PATCH proxmox-backup v2 2/2] ui: s3 endpoint: add provider specific quirk selector Christian Ebner
2025-07-29 13:28 ` [pbs-devel] [PATCH proxmox{, -backup} v2 0/4] s3: extend config by provider-quirks and client options by feature list Lukas Wagner
2025-08-04 6:54 ` [pbs-devel] superseded: " 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=20250729081750.203736-3-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.