[pbs-devel] [PATCH proxmox 1/3] s3-client: early return when request timeout deadline reached

Christian Ebner c.ebner at proxmox.com
Fri Jan 23 15:58:33 CET 2026


The optional timeout value generates a deadline, after which the
request times out and fails, independent from retries.

The current implementation however unneededly continues to loop over
the remaining retires, including potential put rate limit delay and
exponential backoff time, creating unjustified additional latency.

Fix this by early returning with error once the deadline is reached.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
 proxmox-s3-client/src/client.rs | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/proxmox-s3-client/src/client.rs b/proxmox-s3-client/src/client.rs
index 83176b39..5e30aa12 100644
--- a/proxmox-s3-client/src/client.rs
+++ b/proxmox-s3-client/src/client.rs
@@ -386,23 +386,20 @@ impl S3Client {
             }
 
             let response = if let Some(deadline) = deadline {
-                tokio::time::timeout_at(deadline, self.client.request(request)).await
+                tokio::time::timeout_at(deadline, self.client.request(request))
+                    .await
+                    .context("request timeout reached")?
             } else {
-                Ok(self.client.request(request).await)
+                self.client.request(request).await
             };
 
             match response {
-                Ok(Ok(response)) => return Ok(response),
-                Ok(Err(err)) => {
+                Ok(response) => return Ok(response),
+                Err(err) => {
                     if retry >= MAX_S3_HTTP_REQUEST_RETRY - 1 {
                         return Err(err.into());
                     }
                 }
-                Err(_elapsed) => {
-                    if retry >= MAX_S3_HTTP_REQUEST_RETRY - 1 {
-                        bail!("request timed out exceeding retries");
-                    }
-                }
             }
         }
 
-- 
2.47.3





More information about the pbs-devel mailing list