]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: move uri_prefix out of RGWProcessEnv
authorCasey Bodley <cbodley@redhat.com>
Fri, 21 Oct 2022 21:44:44 +0000 (17:44 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 9 Dec 2022 20:20:03 +0000 (15:20 -0500)
each frontend parses its own prefix from the frontend config

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_appmain.cc
src/rgw/rgw_asio_frontend.cc
src/rgw/rgw_frontend.h
src/rgw/rgw_lib.cc
src/rgw/rgw_lib_frontend.h
src/rgw/rgw_process.h

index 5b5d66271973bebc0f1ba4895c523a44b137679e..0ce240b6a9a25b770c7b48fc8aaeeefb1374ece6 100644 (file)
@@ -416,10 +416,7 @@ int rgw::AppMain::init_frontends2(RGWLib* rgwlib)
     RGWFrontend* fe = nullptr;
 
     if (framework == "loadgen") {
-      std::string uri_prefix;
-      config->get_val("prefix", "", &uri_prefix);
-
-      RGWProcessEnv env = {driver, &rest, olog, uri_prefix,
+      RGWProcessEnv env = {driver, &rest, olog,
            auth_registry, ratelimiter.get(), lua_background.get()};
 
       fe = new RGWLoadGenFrontend(env, config);
@@ -427,9 +424,7 @@ int rgw::AppMain::init_frontends2(RGWLib* rgwlib)
     else if (framework == "beast") {
       int port;
       config->get_val("port", 80, &port);
-      std::string uri_prefix;
-      config->get_val("prefix", "", &uri_prefix);
-      RGWProcessEnv env{driver, &rest, olog, uri_prefix,
+      RGWProcessEnv env{driver, &rest, olog,
            auth_registry, ratelimiter.get(), lua_background.get()};
       fe = new RGWAsioFrontend(env, config, *(sched_ctx.get()));
     }
index aecbb395e0708e171c2478457088c17915640398..0e5be90b7cddf49a93c627879055a30302617383 100644 (file)
@@ -183,6 +183,7 @@ void handle_connection(boost::asio::io_context& context,
                        parse_buffer& buffer, bool is_ssl,
                        SharedMutex& pause_mutex,
                        rgw::dmclock::Scheduler *scheduler,
+                       const std::string& uri_prefix,
                        std::unique_ptr<rgw::sal::LuaManager>& lua_manager,
                        boost::system::error_code& ec,
                        yield_context yield)
@@ -270,7 +271,7 @@ void handle_connection(boost::asio::io_context& context,
       string user = "-";
       const auto started = ceph::coarse_real_clock::now();
       ceph::coarse_real_clock::duration latency{};
-      process_request(env.driver, env.rest, &req, env.uri_prefix,
+      process_request(env.driver, env.rest, &req, uri_prefix,
                       *env.auth_registry, &client, env.olog, y,
                       scheduler, &user, &latency,
                       env.ratelimiting->get_active(),
@@ -377,6 +378,7 @@ class AsioFrontend {
   RGWProcessEnv env;
   RGWFrontendConfig* conf;
   boost::asio::io_context context;
+  std::string uri_prefix;
   ceph::timespan request_timeout = std::chrono::milliseconds(REQUEST_TIMEOUT);
   size_t header_limit = 16384;
 #ifdef WITH_RADOSGW_BEAST_OPENSSL
@@ -540,6 +542,10 @@ int AsioFrontend::init()
   boost::system::error_code ec;
   auto& config = conf->get_config_map();
 
+  if (auto i = config.find("prefix"); i != config.end()) {
+    uri_prefix = i->second;
+  }
+
 // Setting global timeout
   auto timeout = config.find("request_timeout_ms");
   if (timeout != config.end()) {
@@ -1013,8 +1019,7 @@ void AsioFrontend::accept(Listener& l, boost::system::error_code ec)
         conn->buffer.consume(bytes);
         handle_connection(context, env, stream, timeout, header_limit,
                           conn->buffer, true, pause_mutex, scheduler.get(),
-                          lua_manager,
-                          ec, yield);
+                          uri_prefix, lua_manager, ec, yield);
         if (!ec) {
           // ssl shutdown (ignoring errors)
           stream.async_shutdown(yield[ec]);
@@ -1033,8 +1038,7 @@ void AsioFrontend::accept(Listener& l, boost::system::error_code ec)
         boost::system::error_code ec;
         handle_connection(context, env, conn->socket, timeout, header_limit,
                           conn->buffer, false, pause_mutex, scheduler.get(),
-                          lua_manager,
-                          ec, yield);
+                          uri_prefix, lua_manager, ec, yield);
         conn->socket.shutdown(tcp_socket::shutdown_both, ec);
       }, make_stack_allocator());
   }
index b5c3b728cd6468c387ad2dd86ffc49f46cfbd81e..3fd5bd01ec7afad4c7951421722f343cec1faf30 100644 (file)
@@ -152,8 +152,11 @@ public:
   int init() override {
     int num_threads;
     conf->get_val("num_threads", g_conf()->rgw_thread_pool_size, &num_threads);
-    RGWLoadGenProcess *pp = new RGWLoadGenProcess(g_ceph_context, &env,
-                                                 num_threads, conf);
+    std::string uri_prefix;
+    conf->get_val("prefix", "", &uri_prefix);
+
+    RGWLoadGenProcess *pp = new RGWLoadGenProcess(
+        g_ceph_context, &env, num_threads, std::move(uri_prefix), conf);
 
     pprocess = pp;
 
index 04c5db8fdf247fa18966d20e5725f9971c452404..5ed976cfd271c1438cf7ad091a076a41d6725b8e 100644 (file)
@@ -449,8 +449,9 @@ namespace rgw {
 
   int RGWLibFrontend::init()
   {
+    std::string uri_prefix; // empty
     pprocess = new RGWLibProcess(g_ceph_context, &env,
-                                g_conf()->rgw_thread_pool_size, conf);
+                                g_conf()->rgw_thread_pool_size, uri_prefix, conf);
     return 0;
   }
 
index 625952d335df0d9ca82efa222ac24b8d9904d698..4754362a6e31c9633e9976f6fb084f20bbb64289 100644 (file)
@@ -26,8 +26,9 @@ namespace rgw {
 
   public:
     RGWLibProcess(CephContext* cct, RGWProcessEnv* pe, int num_threads,
-                 RGWFrontendConfig* _conf) :
-      RGWProcess(cct, pe, num_threads, _conf), gen(0), shutdown(false) {}
+                 std::string uri_prefix, RGWFrontendConfig* _conf) :
+      RGWProcess(cct, pe, num_threads, std::move(uri_prefix), _conf),
+      gen(0), shutdown(false) {}
 
     void run() override;
     void checkpoint();
index 7e65accae759bb6c4835b15abac2442ab3bab57b..4a8a35c77bf1a7a9645b824c75a338e8e8ba2ab0 100644 (file)
@@ -32,7 +32,6 @@ struct RGWProcessEnv {
   rgw::sal::Driver* driver = nullptr;
   RGWREST *rest = nullptr;
   OpsLogSink *olog = nullptr;
-  std::string uri_prefix;
   std::shared_ptr<rgw::auth::StrategyRegistry> auth_registry;
   ActiveRateLimiter* ratelimiting = nullptr;
   rgw::lua::Background* lua_background = nullptr;
@@ -96,6 +95,7 @@ public:
   RGWProcess(CephContext* const cct,
              RGWProcessEnv* const pe,
              const int num_threads,
+             std::string uri_prefix,
              RGWFrontendConfig* const conf)
     : cct(cct),
       driver(pe->driver),
@@ -106,7 +106,7 @@ public:
       rest(pe->rest),
       conf(conf),
       sock_fd(-1),
-      uri_prefix(pe->uri_prefix),
+      uri_prefix(std::move(uri_prefix)),
       lua_background(pe->lua_background),
       lua_manager(driver->get_lua_manager()),
       req_wq(this,
@@ -155,8 +155,8 @@ class RGWLoadGenProcess : public RGWProcess {
   RGWAccessKey access_key;
 public:
   RGWLoadGenProcess(CephContext* cct, RGWProcessEnv* pe, int num_threads,
-                 RGWFrontendConfig* _conf) :
-  RGWProcess(cct, pe, num_threads, _conf) {}
+                    std::string uri_prefix, RGWFrontendConfig* _conf)
+    : RGWProcess(cct, pe, num_threads, std::move(uri_prefix), _conf) {}
   void run() override;
   void checkpoint();
   void handle_request(const DoutPrefixProvider *dpp, RGWRequest* req) override;