From: Casey Bodley Date: Fri, 21 Oct 2022 21:44:44 +0000 (-0400) Subject: rgw: move uri_prefix out of RGWProcessEnv X-Git-Tag: v18.1.0~650^2~12 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=957a6e951c2305a815b539f36f2bbcc863f16907;p=ceph.git rgw: move uri_prefix out of RGWProcessEnv each frontend parses its own prefix from the frontend config Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_appmain.cc b/src/rgw/rgw_appmain.cc index 5b5d66271973b..0ce240b6a9a25 100644 --- a/src/rgw/rgw_appmain.cc +++ b/src/rgw/rgw_appmain.cc @@ -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())); } diff --git a/src/rgw/rgw_asio_frontend.cc b/src/rgw/rgw_asio_frontend.cc index aecbb395e0708..0e5be90b7cddf 100644 --- a/src/rgw/rgw_asio_frontend.cc +++ b/src/rgw/rgw_asio_frontend.cc @@ -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& 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()); } diff --git a/src/rgw/rgw_frontend.h b/src/rgw/rgw_frontend.h index b5c3b728cd646..3fd5bd01ec7af 100644 --- a/src/rgw/rgw_frontend.h +++ b/src/rgw/rgw_frontend.h @@ -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; diff --git a/src/rgw/rgw_lib.cc b/src/rgw/rgw_lib.cc index 04c5db8fdf247..5ed976cfd271c 100644 --- a/src/rgw/rgw_lib.cc +++ b/src/rgw/rgw_lib.cc @@ -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; } diff --git a/src/rgw/rgw_lib_frontend.h b/src/rgw/rgw_lib_frontend.h index 625952d335df0..4754362a6e31c 100644 --- a/src/rgw/rgw_lib_frontend.h +++ b/src/rgw/rgw_lib_frontend.h @@ -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(); diff --git a/src/rgw/rgw_process.h b/src/rgw/rgw_process.h index 7e65accae759b..4a8a35c77bf1a 100644 --- a/src/rgw/rgw_process.h +++ b/src/rgw/rgw_process.h @@ -32,7 +32,6 @@ struct RGWProcessEnv { rgw::sal::Driver* driver = nullptr; RGWREST *rest = nullptr; OpsLogSink *olog = nullptr; - std::string uri_prefix; std::shared_ptr 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;