From 98772afc55787d81f2da867a84b66c653f90b9d1 Mon Sep 17 00:00:00 2001 From: Seena Fallah Date: Sun, 1 Dec 2024 16:24:56 +0100 Subject: [PATCH] rgw: handle EINVAL translation in forward_request 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 --- src/rgw/rgw_rest_client.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_rest_client.cc b/src/rgw/rgw_rest_client.cc index c16064a61c2b..a5f8cb61a328 100644 --- a/src/rgw/rgw_rest_client.cc +++ b/src/rgw/rgw_rest_client.cc @@ -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; -- 2.47.3