]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: handle EINVAL translation in forward_request 60899/head
authorSeena Fallah <seenafallah@gmail.com>
Sun, 1 Dec 2024 15:24:56 +0000 (16:24 +0100)
committerSeena Fallah <seenafallah@gmail.com>
Thu, 5 Dec 2024 19:13:54 +0000 (20:13 +0100)
RGWRESTSimpleRequest::forward_request() translates EINVAL to a 503
status code to reflect connection errors as internal errors rather
than client errors. However, if the master is explicitly returning
EINVAL (which corresponds to an HTTP 400 status code), this
translation incorrectly converts it to 503, hiding the true client
error.

To address this, we now check the HTTP status code to ensure the
error originates from easy_curl and not from a valid HTTP response,
preserving the intended 400 status when appropriate.

Fixes: https://tracker.ceph.com/issues/69084
Signed-off-by: Seena Fallah <seenafallah@gmail.com>
src/rgw/rgw_rest_client.cc

index c16064a61c2b3edae173640abbda62690da22658..a5f8cb61a3286f5538b98e6227ac719cfe5204ed 100644 (file)
@@ -453,9 +453,9 @@ int RGWRESTSimpleRequest::forward_request(const DoutPrefixProvider *dpp, const R
   url = new_url;
 
   int r = process(dpp, y);
-  if (r < 0){
-    if (r == -EINVAL){
-      // curl_easy has errored, generally means the service is not available
+  if (r < 0) {
+    if (http_status == 0) {
+      // no http status, generally means the service is not available
       r = -ERR_SERVICE_UNAVAILABLE;
     }
     return r;