From: Oguzhan Ozmen Date: Sat, 7 Feb 2026 17:33:42 +0000 (+0000) Subject: rgw: track original URL within RGWEndpoint instead of separate member (refactor) X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b8d8c40edcc176b8f07bb143cbe2269e05f4bed8;p=ceph.git rgw: track original URL within RGWEndpoint instead of separate member (refactor) Refactor endpoint tracking by adding original_url to RGWEndpoint struct instead of maintaining a separate endpoint_orig member in RGWHTTPClient. This simplifies the code by having each endpoint self-track its original URL, which is needed for connection status lookups after URL modifications. No functional changes intended. Signed-off-by: Oguzhan Ozmen --- diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index 788b18f6fa1..94ed211c8c4 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -310,7 +310,6 @@ RGWHTTPClient::RGWHTTPClient(CephContext *cct, verify_ssl(cct->_conf->rgw_verify_ssl), cct(cct), method(_method), - endpoint_orig(_endpoint), endpoint(_endpoint) { init(); } diff --git a/src/rgw/rgw_http_client.h b/src/rgw/rgw_http_client.h index 6eaf1844401..942824aa9d6 100644 --- a/src/rgw/rgw_http_client.h +++ b/src/rgw/rgw_http_client.h @@ -20,9 +20,24 @@ void rgw_http_client_cleanup(); struct rgw_http_req_data; class RGWHTTPManager; +/** + * RGWEndpoint - Represents an HTTP endpoint with additional metdata such as connection routing. + * + * Unlike a plain URL string, RGWEndpoint carries additional information needed + * to leverage libcurl's CURLOPT_CONNECT_TO option. This enables RGW to route + * requests to specific IP addresses while preserving the original hostname for + * TLS/SNI and Host headers. + * + * Fields: + * - url: The effective URL for the request (may be modified with paths). + * - original_url: The initially configured endpoint URL (preserved for reference). + * - connect_to: libcurl CONNECT_TO string (format: "host:port:addr:port") to + * override connection routing without changing the request URL. + */ struct RGWEndpoint { private: std::string url; + std::string original_url; std::string connect_to; public: @@ -31,7 +46,7 @@ public: RGWEndpoint(const char* u) : RGWEndpoint(std::string(u)) {} RGWEndpoint(std::string u, std::string c = {}) - : url(std::move(u)), connect_to(std::move(c)) {} + : url(std::move(u)), original_url(url), connect_to(std::move(c)) {} RGWEndpoint with_url(std::string new_url) const { RGWEndpoint e = *this; @@ -39,8 +54,15 @@ public: return e; } - void set_url(const std::string& _url) { url = _url; } + void set_url(const std::string& _url) { + url = _url; + // Capture the first URL assignment as the original + if (original_url.empty()) { + original_url = _url; + } + } const std::string& get_url() const { return url; } + const std::string& get_original_url() const { return original_url; } void set_connect_to(const std::string& _connect_to) { connect_to = _connect_to; } const std::string& get_connect_to() const { return connect_to; } @@ -86,7 +108,6 @@ protected: CephContext *cct; std::string method; - RGWEndpoint endpoint_orig; RGWEndpoint endpoint; std::string protocol; @@ -204,6 +225,10 @@ public: int get_req_retcode(); + const RGWEndpoint& get_endpoint() const { + return endpoint; + } + void set_endpoint(const RGWEndpoint& _endpoint) { endpoint = _endpoint; } @@ -212,10 +237,6 @@ public: endpoint.set_url(_url); } - const RGWEndpoint& get_endpoint_orig() const { - return endpoint_orig; - } - void set_method(const std::string& _method) { method = _method; } diff --git a/src/rgw/rgw_rest_client.h b/src/rgw/rgw_rest_client.h index e9458f44f7e..47d60b8ba7f 100644 --- a/src/rgw/rgw_rest_client.h +++ b/src/rgw/rgw_rest_client.h @@ -101,7 +101,7 @@ public: void set_policy(const RGWAccessControlPolicy& policy); int sign(const DoutPrefixProvider *dpp, RGWAccessKey& key, const bufferlist *opt_content); - const RGWEndpoint& get_endpoint() { return endpoint; } + const RGWEndpoint& get_endpoint() const { return endpoint; } }; class RGWHTTPStreamRWRequest : public RGWHTTPSimpleRequest { diff --git a/src/rgw/rgw_rest_conn.cc b/src/rgw/rgw_rest_conn.cc index 727cef4331c..6c86d4e29fd 100644 --- a/src/rgw/rgw_rest_conn.cc +++ b/src/rgw/rgw_rest_conn.cc @@ -231,17 +231,17 @@ RGWEndpoint RGWRESTConn::get_endpoint() void RGWRESTConn::set_endpoint_unconnectable(const RGWEndpoint& endpoint) { - const string& url = endpoint.get_url(); + const string& orig_url = endpoint.get_original_url(); - if (url.empty() || resolved_endpoints.find(url) == resolved_endpoints.end()) { - ldout(cct, 0) << "ERROR: endpoint is not a valid or doesn't have status. endpoint=" - << url << dendl; + if (orig_url.empty() || resolved_endpoints.find(orig_url) == resolved_endpoints.end()) { + ldout(cct, 0) << "ERROR: endpoint is not a valid or doesn't have status. " + << " original_url=" << orig_url << " current_url=" << endpoint.get_url() << dendl; return; } - resolved_endpoints[url].status.store(ceph::real_clock::now()); + resolved_endpoints[orig_url].status.store(ceph::real_clock::now()); - ldout(cct, 10) << "set endpoint unconnectable. url=" << url << dendl; + ldout(cct, 10) << "set endpoint unconnectable. url=" << orig_url << dendl; } void RGWRESTConn::populate_params(param_vec_t& params, const rgw_owner* uid, const string& zonegroup) @@ -357,7 +357,7 @@ int RGWRESTConn::complete_request(const DoutPrefixProvider* dpp, int ret = req->complete_request(dpp, y, &etag, mtime); if (ret == -EIO) { ldout(cct, 5) << __func__ << ": complete_request() returned ret=" << ret << dendl; - set_endpoint_unconnectable(req->get_endpoint_orig()); + set_endpoint_unconnectable(req->get_endpoint()); } delete req; @@ -520,7 +520,7 @@ int RGWRESTConn::complete_request(const DoutPrefixProvider* dpp, int ret = req->complete_request(dpp, y, etag, mtime, psize, pattrs, pheaders); if (ret == -EIO) { ldout(cct, 5) << __func__ << ": complete_request() returned ret=" << ret << dendl; - set_endpoint_unconnectable(req->get_endpoint_orig()); + set_endpoint_unconnectable(req->get_endpoint()); } delete req; @@ -683,7 +683,7 @@ int RGWRESTReadResource::read(const DoutPrefixProvider *dpp, optional_yield y) ret = req.complete_request(dpp, y); if (ret == -EIO) { - conn->set_endpoint_unconnectable(req.get_endpoint_orig()); + conn->set_endpoint_unconnectable(req.get_endpoint()); ldpp_dout(dpp, 20) << __func__ << ": complete_request() returned ret=" << ret << dendl; } @@ -750,7 +750,7 @@ int RGWRESTSendResource::send(const DoutPrefixProvider *dpp, bufferlist& outbl, ret = req.complete_request(dpp, y); if (ret == -EIO) { - conn->set_endpoint_unconnectable(req.get_endpoint_orig()); + conn->set_endpoint_unconnectable(req.get_endpoint()); ldpp_dout(dpp, 20) << __func__ << ": complete_request() returned ret=" << ret << dendl; } diff --git a/src/rgw/rgw_rest_conn.h b/src/rgw/rgw_rest_conn.h index 700d06f5407..29613d62820 100644 --- a/src/rgw/rgw_rest_conn.h +++ b/src/rgw/rgw_rest_conn.h @@ -405,7 +405,7 @@ public: int ret = req.wait(dpp, y); if (ret < 0) { if (ret == -ERR_INTERNAL_ERROR) { - conn->set_endpoint_unconnectable(req.get_endpoint_orig()); + conn->set_endpoint_unconnectable(req.get_endpoint()); } return ret; } @@ -461,7 +461,7 @@ int RGWRESTReadResource::wait(const DoutPrefixProvider* dpp, T *dest, int ret = req.wait(dpp, y); if (ret < 0) { if (ret == -ERR_INTERNAL_ERROR) { - conn->set_endpoint_unconnectable(req.get_endpoint_orig()); + conn->set_endpoint_unconnectable(req.get_endpoint()); } return ret; } @@ -536,7 +536,7 @@ public: *pbl = bl; if (ret == -ERR_INTERNAL_ERROR) { - conn->set_endpoint_unconnectable(req.get_endpoint_orig()); + conn->set_endpoint_unconnectable(req.get_endpoint()); } if (ret < 0 && err_result ) { @@ -557,7 +557,7 @@ int RGWRESTSendResource::wait(const DoutPrefixProvider* dpp, T *dest, { int ret = req.wait(dpp, y); if (ret == -ERR_INTERNAL_ERROR) { - conn->set_endpoint_unconnectable(req.get_endpoint_orig()); + conn->set_endpoint_unconnectable(req.get_endpoint()); } if (ret >= 0) {