From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox v2 3/3] fix #6858: s3-client: retry request on 500, 503 and 504 status codes
Date: Tue, 24 Feb 2026 14:49:44 +0100 [thread overview]
Message-ID: <20260224134944.593408-4-c.ebner@proxmox.com> (raw)
In-Reply-To: <20260224134944.593408-1-c.ebner@proxmox.com>
Follow the best practices for AWS S3 error handling [0] and perform
retries on requests with http status code 500 or 503 in the response.
Further, do the same for 504 gateway timeout errors encountered by
some users in the community forum [1] in combination with Hetzner's
S3 storage offerings.
This is done for all requests unconditionally, maximum number of
retires and optional request timeout being honored.
[0] https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorBestPractices.html
[1] https://forum.proxmox.com/threads/180956/
Fixes: https://bugzilla.proxmox.com/show_bug.cgi?id=6858
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
changes since version 1:
- return the last error if retries are exhausted
- consider also 504 gateway timeout as retryable
proxmox-s3-client/src/client.rs | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/proxmox-s3-client/src/client.rs b/proxmox-s3-client/src/client.rs
index f3e5eb45..35c80948 100644
--- a/proxmox-s3-client/src/client.rs
+++ b/proxmox-s3-client/src/client.rs
@@ -388,13 +388,18 @@ impl S3Client {
self.client.request(request).await
};
- match response {
- Ok(response) => return Ok(response),
- Err(err) => {
- if retry >= MAX_S3_HTTP_REQUEST_RETRY - 1 {
- return Err(err.into());
- }
- }
+ let do_retry = match &response {
+ Ok(response) => matches!(
+ response.status(),
+ StatusCode::INTERNAL_SERVER_ERROR
+ | StatusCode::SERVICE_UNAVAILABLE
+ | StatusCode::GATEWAY_TIMEOUT
+ ),
+ Err(_) => true,
+ };
+
+ if !do_retry || retry >= MAX_S3_HTTP_REQUEST_RETRY - 1 {
+ return Ok(response?);
}
let backoff_secs = S3_HTTP_REQUEST_RETRY_BACKOFF_DEFAULT * 3_u32.pow(retry as u32);
--
2.47.3
prev parent reply other threads:[~2026-02-24 13:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 13:49 [PATCH proxmox v2 0/3] fix #6858: implement retry logic for transient API errors Christian Ebner
2026-02-24 13:49 ` [PATCH proxmox v2 1/3] s3-client: early return when request timeout deadline reached Christian Ebner
2026-02-24 13:49 ` [PATCH proxmox v2 2/3] s3-client: move exponential backoff to after the response state check Christian Ebner
2026-02-24 13:49 ` Christian Ebner [this message]
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=20260224134944.593408-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox