]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: track original URL within RGWEndpoint instead of separate member (refactor)
authorOguzhan Ozmen <oozmen@bloomberg.net>
Sat, 7 Feb 2026 17:33:42 +0000 (17:33 +0000)
committerOguzhan Ozmen <oozmen@bloomberg.net>
Tue, 2 Jun 2026 22:16:20 +0000 (22:16 +0000)
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 <oozmen@bloomberg.net>
src/rgw/rgw_http_client.cc
src/rgw/rgw_http_client.h
src/rgw/rgw_rest_client.h
src/rgw/rgw_rest_conn.cc
src/rgw/rgw_rest_conn.h

index 788b18f6fa16a7f7fdfd8defd8fa53daee5a2d17..94ed211c8c47184a4baeabb46be4deceb983abf2 100644 (file)
@@ -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();
 }
index 6eaf1844401562766bd61385c84beff534a8dd92..942824aa9d6ca91282eb42bfb2d092b53a790305 100644 (file)
@@ -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;
   }
index e9458f44f7e8c4e1d62a554ca2ff5806fed21973..47d60b8ba7f0a6da5a2d6b5db70e7f8f439f0775 100644 (file)
@@ -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 {
index 727cef4331ce992afcee9bf1acd6ba799b176818..6c86d4e29fd97650c66c0d1d103f3458318867d0 100644 (file)
@@ -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;
   }
 
index 700d06f54075e06aa3e80fd246e6422932afc8b7..29613d628200819d1d30268f071410f05502ccba 100644 (file)
@@ -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) {