]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rgw/rgw_asio_frontend.cc
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rgw / rgw_asio_frontend.cc
index dac47d36a7bfe6c5b7289a66c178293d5813df7a..633a2963300f60b2e10c809a185daa2bc6f00a85 100644 (file)
@@ -192,13 +192,14 @@ 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,
                        boost::system::error_code& ec,
                        yield_context yield)
 {
   // don't impose a limit on the body, since we read it in pieces
   static constexpr size_t body_limit = std::numeric_limits<size_t>::max();
 
-  auto cct = env.store->ctx();
+  auto cct = env.driver->ctx();
 
   // read messages from the stream until eof
   for (;;) {
@@ -249,7 +250,7 @@ void handle_connection(boost::asio::io_context& context,
       }
 
       // process the request
-      RGWRequest req{env.store->get_new_req_id()};
+      RGWRequest req{env.driver->get_new_req_id()};
 
       auto& socket = stream.lowest_layer();
       const auto& remote_endpoint = socket.remote_endpoint(ec);
@@ -257,10 +258,14 @@ void handle_connection(boost::asio::io_context& context,
         ldout(cct, 1) << "failed to connect client: " << ec.message() << dendl;
         return;
       }
+      const auto& local_endpoint = socket.local_endpoint(ec);
+      if (ec) {
+        ldout(cct, 1) << "failed to connect client: " << ec.message() << dendl;
+        return;
+      }
 
       StreamIO real_client{cct, stream, timeout, parser, yield, buffer,
-                           is_ssl, socket.local_endpoint(),
-                           remote_endpoint};
+                           is_ssl, local_endpoint, remote_endpoint};
 
       auto real_client_io = rgw::io::add_reordering(
                               rgw::io::add_buffering(cct,
@@ -276,15 +281,12 @@ 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.store, env.rest, &req, env.uri_prefix,
-                      *env.auth_registry, &client, env.olog, y,
-                      scheduler, &user, &latency,
-                      env.ratelimiting->get_active(),
-                      &http_ret);
+      process_request(env, &req, uri_prefix, &client, y,
+                      scheduler, &user, &latency, &http_ret);
 
-      if (cct->_conf->subsys.should_gather(dout_subsys, 1)) {
+      if (cct->_conf->subsys.should_gather(ceph_subsys_rgw_access, 1)) {
         // access log line elements begin per Apache Combined Log Format with additions following
-        ldout(cct, 1) << "beast: " << std::hex << &req << std::dec << ": "
+        lsubdout(cct, rgw_access, 1) << "beast: " << std::hex << &req << std::dec << ": "
             << remote_endpoint.address() << " - " << user << " [" << log_apache_time{started} << "] \""
             << message.method_string() << ' ' << message.target() << ' '
             << http_version{message.version()} << "\" " << http_ret << ' '
@@ -391,9 +393,10 @@ class ConnectionList {
 
 namespace dmc = rgw::dmclock;
 class AsioFrontend {
-  RGWProcessEnv env;
+  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
@@ -429,13 +432,13 @@ class AsioFrontend {
   std::vector<std::thread> threads;
   std::atomic<bool> going_down{false};
 
-  CephContext* ctx() const { return env.store->ctx(); }
+  CephContext* ctx() const { return env.driver->ctx(); }
   std::optional<dmc::ClientCounters> client_counters;
   std::unique_ptr<dmc::ClientConfig> client_config;
   void accept(Listener& listener, boost::system::error_code ec);
 
  public:
-  AsioFrontend(const RGWProcessEnv& env, RGWFrontendConfig* conf,
+  AsioFrontend(RGWProcessEnv& env, RGWFrontendConfig* conf,
               dmc::SchedulerCtx& sched_ctx)
     : env(env), conf(conf), pause_mutex(context.get_executor())
   {
@@ -463,7 +466,7 @@ class AsioFrontend {
   void stop();
   void join();
   void pause();
-  void unpause(rgw::sal::Store* store, rgw_auth_registry_ptr_t);
+  void unpause();
 };
 
 unsigned short parse_port(const char *input, boost::system::error_code& ec)
@@ -555,6 +558,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()) {
@@ -695,12 +702,12 @@ class ExpandMetaVar {
 
 public:
   ExpandMetaVar(rgw::sal::Zone* zone_svc) {
-    meta_map["realm"] = zone_svc->get_realm().get_name();
-    meta_map["realm_id"] = zone_svc->get_realm().get_id();
+    meta_map["realm"] = zone_svc->get_realm_name();
+    meta_map["realm_id"] = zone_svc->get_realm_id();
     meta_map["zonegroup"] = zone_svc->get_zonegroup().get_name();
     meta_map["zonegroup_id"] = zone_svc->get_zonegroup().get_id();
     meta_map["zone"] = zone_svc->get_name();
-    meta_map["zone_id"] = zone_svc->get_id().id;
+    meta_map["zone_id"] = zone_svc->get_id();
   }
 
   string process_str(const string& in);
@@ -774,7 +781,7 @@ int AsioFrontend::get_config_key_val(string name,
     return -EINVAL;
   }
 
-  int r = env.store->get_config_key_val(name, pbl);
+  int r = env.driver->get_config_key_val(name, pbl);
   if (r < 0) {
     lderr(ctx()) << type << " was not found: " << name << dendl;
     return r;
@@ -930,7 +937,7 @@ int AsioFrontend::init_ssl()
       key_is_cert = true;
     }
 
-    ExpandMetaVar emv(env.store->get_zone());
+    ExpandMetaVar emv(env.driver->get_zone());
 
     cert = emv.process_str(*cert);
     key = emv.process_str(*key);
@@ -1028,7 +1035,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(),
-                          ec, yield);
+                          uri_prefix, ec, yield);
         if (!ec) {
           // ssl shutdown (ignoring errors)
           stream.async_shutdown(yield[ec]);
@@ -1047,7 +1054,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(),
-                          ec, yield);
+                          uri_prefix, ec, yield);
         conn->socket.shutdown(tcp_socket::shutdown_both, ec);
       }, make_stack_allocator());
   }
@@ -1066,7 +1073,7 @@ int AsioFrontend::run()
   work.emplace(boost::asio::make_work_guard(context));
 
   for (int i = 0; i < thread_count; i++) {
-    threads.emplace_back([=]() noexcept {
+    threads.emplace_back([this]() noexcept {
       // request warnings on synchronous librados calls in this thread
       is_asio_thread = true;
       // Have uncaught exceptions kill the process and give a
@@ -1127,12 +1134,8 @@ void AsioFrontend::pause()
   }
 }
 
-void AsioFrontend::unpause(rgw::sal::Store* const store,
-                           rgw_auth_registry_ptr_t auth_registry)
+void AsioFrontend::unpause()
 {
-  env.store = store;
-  env.auth_registry = std::move(auth_registry);
-
   // unpause to unblock connections
   pause_mutex.unlock();
 
@@ -1151,12 +1154,12 @@ void AsioFrontend::unpause(rgw::sal::Store* const store,
 
 class RGWAsioFrontend::Impl : public AsioFrontend {
  public:
-  Impl(const RGWProcessEnv& env, RGWFrontendConfig* conf,
+  Impl(RGWProcessEnv& env, RGWFrontendConfig* conf,
        rgw::dmclock::SchedulerCtx& sched_ctx)
     : AsioFrontend(env, conf, sched_ctx) {}
 };
 
-RGWAsioFrontend::RGWAsioFrontend(const RGWProcessEnv& env,
+RGWAsioFrontend::RGWAsioFrontend(RGWProcessEnv& env,
                                  RGWFrontendConfig* conf,
                                 rgw::dmclock::SchedulerCtx& sched_ctx)
   : impl(new Impl(env, conf, sched_ctx))
@@ -1190,9 +1193,7 @@ void RGWAsioFrontend::pause_for_new_config()
   impl->pause();
 }
 
-void RGWAsioFrontend::unpause_with_new_config(
-  rgw::sal::Store* const store,
-  rgw_auth_registry_ptr_t auth_registry
-) {
-  impl->unpause(store, std::move(auth_registry));
+void RGWAsioFrontend::unpause_with_new_config()
+{
+  impl->unpause();
 }