From: Casey Bodley Date: Tue, 11 May 2021 13:42:53 +0000 (-0400) Subject: rgw: remove the civetweb frontend from src and qa X-Git-Tag: v17.1.0~1940^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=46c0292870ce9483ddf15bcaf2dcc9554dfb48a0;p=ceph.git rgw: remove the civetweb frontend from src and qa Signed-off-by: Casey Bodley --- diff --git a/.gitmodules b/.gitmodules index 9a4c7e7a9180..da854248121a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "ceph-object-corpus"] path = ceph-object-corpus url = https://github.com/ceph/ceph-object-corpus.git -[submodule "src/civetweb"] - path = src/civetweb - url = https://github.com/ceph/civetweb [submodule "src/erasure-code/jerasure/jerasure"] path = src/erasure-code/jerasure/jerasure url = https://github.com/ceph/jerasure.git diff --git a/doc/radosgw/frontends.rst b/doc/radosgw/frontends.rst index 124dd9665023..7deeea29208f 100644 --- a/doc/radosgw/frontends.rst +++ b/doc/radosgw/frontends.rst @@ -96,85 +96,6 @@ Options :Default: ``65000`` -Civetweb -======== - -.. versionadded:: Firefly -.. deprecated:: Pacific - -The ``civetweb`` frontend uses the Civetweb HTTP library, which is a -fork of Mongoose. - - -Options -------- - -``port`` - -:Description: Sets the listening port number. For SSL-enabled ports, add an - ``s`` suffix like ``443s``. To bind a specific IPv4 or IPv6 - address, use the form ``address:port``. Multiple endpoints - can either be separated by ``+`` as in ``127.0.0.1:8000+443s``, - or by providing multiple options as in ``port=8000 port=443s``. - -:Type: String -:Default: ``7480`` - - -``num_threads`` - -:Description: Sets the number of threads spawned by Civetweb to handle - incoming HTTP connections. This effectively limits the number - of concurrent connections that the frontend can service. - -:Type: Integer -:Default: ``rgw_thread_pool_size`` - - -``request_timeout_ms`` - -:Description: The amount of time in milliseconds that Civetweb will wait - for more incoming data before giving up. - -:Type: Integer -:Default: ``30000`` - - -``ssl_certificate`` - -:Description: Path to the SSL certificate file used for SSL-enabled ports. - -:Type: String -:Default: None - -``access_log_file`` - -:Description: Path to a file for access logs. Either full path, or relative - to the current working directory. If absent (default), then - accesses are not logged. - -:Type: String -:Default: ``EMPTY`` - - -``error_log_file`` - -:Description: Path to a file for error logs. Either full path, or relative - to the current working directory. If absent (default), then - errors are not logged. - -:Type: String -:Default: ``EMPTY`` - - -The following is an example of the ``/etc/ceph/ceph.conf`` file with some of these options set: :: - - [client.rgw.gateway-node1] - rgw_frontends = civetweb request_timeout_ms=30000 error_log_file=/var/log/radosgw/civetweb.error.log access_log_file=/var/log/radosgw/civetweb.access.log - -A complete list of supported options can be found in the `Civetweb User Manual`_. - - Generic Options =============== @@ -190,5 +111,4 @@ Some frontend options are generic and supported by all frontends: :Default: None -.. _Civetweb User Manual: https://civetweb.github.io/civetweb/UserManual.html .. _Config Reference: ../config-ref diff --git a/qa/rgw_frontend/civetweb.yaml b/qa/rgw_frontend/civetweb.yaml deleted file mode 100644 index 5845a0e6c15c..000000000000 --- a/qa/rgw_frontend/civetweb.yaml +++ /dev/null @@ -1,3 +0,0 @@ -overrides: - rgw: - frontend: civetweb diff --git a/qa/suites/rgw/multifs/frontend b/qa/suites/rgw/multifs/frontend new file mode 120000 index 000000000000..926a53e83834 --- /dev/null +++ b/qa/suites/rgw/multifs/frontend @@ -0,0 +1 @@ +.qa/rgw_frontend \ No newline at end of file diff --git a/qa/suites/rgw/multifs/frontend/.qa b/qa/suites/rgw/multifs/frontend/.qa deleted file mode 120000 index a602a0353e75..000000000000 --- a/qa/suites/rgw/multifs/frontend/.qa +++ /dev/null @@ -1 +0,0 @@ -../.qa/ \ No newline at end of file diff --git a/qa/suites/rgw/multifs/frontend/civetweb.yaml b/qa/suites/rgw/multifs/frontend/civetweb.yaml deleted file mode 120000 index f9115ff4a7ce..000000000000 --- a/qa/suites/rgw/multifs/frontend/civetweb.yaml +++ /dev/null @@ -1 +0,0 @@ -.qa/rgw_frontend/civetweb.yaml \ No newline at end of file diff --git a/qa/suites/rgw/singleton/frontend b/qa/suites/rgw/singleton/frontend new file mode 120000 index 000000000000..926a53e83834 --- /dev/null +++ b/qa/suites/rgw/singleton/frontend @@ -0,0 +1 @@ +.qa/rgw_frontend \ No newline at end of file diff --git a/qa/suites/rgw/singleton/frontend/.qa b/qa/suites/rgw/singleton/frontend/.qa deleted file mode 120000 index a602a0353e75..000000000000 --- a/qa/suites/rgw/singleton/frontend/.qa +++ /dev/null @@ -1 +0,0 @@ -../.qa/ \ No newline at end of file diff --git a/qa/suites/rgw/singleton/frontend/civetweb.yaml b/qa/suites/rgw/singleton/frontend/civetweb.yaml deleted file mode 120000 index f9115ff4a7ce..000000000000 --- a/qa/suites/rgw/singleton/frontend/civetweb.yaml +++ /dev/null @@ -1 +0,0 @@ -.qa/rgw_frontend/civetweb.yaml \ No newline at end of file diff --git a/qa/suites/rgw/thrash/civetweb.yaml b/qa/suites/rgw/thrash/civetweb.yaml deleted file mode 100644 index db4b04339131..000000000000 --- a/qa/suites/rgw/thrash/civetweb.yaml +++ /dev/null @@ -1,8 +0,0 @@ -overrides: - ceph: - conf: - client: - setuser: ceph - setgroup: ceph - rgw: - frontend: civetweb diff --git a/qa/suites/rgw/thrash/frontend b/qa/suites/rgw/thrash/frontend new file mode 120000 index 000000000000..926a53e83834 --- /dev/null +++ b/qa/suites/rgw/thrash/frontend @@ -0,0 +1 @@ +.qa/rgw_frontend \ No newline at end of file diff --git a/qa/suites/smoke/basic/tasks/test/rgw_ec_s3tests.yaml b/qa/suites/smoke/basic/tasks/test/rgw_ec_s3tests.yaml index 8d1c9fc72a31..a57399a5d66d 100644 --- a/qa/suites/smoke/basic/tasks/test/rgw_ec_s3tests.yaml +++ b/qa/suites/smoke/basic/tasks/test/rgw_ec_s3tests.yaml @@ -2,7 +2,6 @@ overrides: rgw: ec-data-pool: true cache-pools: true - frontend: civetweb tasks: - ceph: - rgw: [client.0] diff --git a/qa/suites/teuthology/rgw/tasks/s3tests-civetweb.yaml b/qa/suites/teuthology/rgw/tasks/s3tests-civetweb.yaml deleted file mode 100644 index 7d39cfbe9202..000000000000 --- a/qa/suites/teuthology/rgw/tasks/s3tests-civetweb.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# this runs s3tests against rgw, using civetweb -roles: -- [mon.a, mon.c, osd.0, osd.1, osd.2, client.0] -- [mon.b, mgr.x, osd.3, osd.4, osd.5, client.1] - -tasks: -- install: - branch: master -- ceph: -- rgw: [client.0] -- s3tests: - client.0: - rgw_server: client.0 - force-branch: ceph-master -overrides: - ceph: - fs: xfs - conf: - client: - debug rgw: 20 - rgw lc debug interval: 10 - rgw: - ec-data-pool: false - frontend: civetweb diff --git a/qa/suites/teuthology/rgw/tasks/s3tests.yaml b/qa/suites/teuthology/rgw/tasks/s3tests.yaml new file mode 100644 index 000000000000..ee8e9d5b5dc3 --- /dev/null +++ b/qa/suites/teuthology/rgw/tasks/s3tests.yaml @@ -0,0 +1,23 @@ +# this runs s3tests against rgw +roles: +- [mon.a, mon.c, osd.0, osd.1, osd.2, client.0] +- [mon.b, mgr.x, osd.3, osd.4, osd.5, client.1] + +tasks: +- install: + branch: master +- ceph: +- rgw: [client.0] +- s3tests: + client.0: + rgw_server: client.0 + force-branch: ceph-master +overrides: + ceph: + fs: xfs + conf: + client: + debug rgw: 20 + rgw lc debug interval: 10 + rgw: + ec-data-pool: false diff --git a/qa/tasks/rgw.py b/qa/tasks/rgw.py index 49b99819e24e..6961d060c42b 100644 --- a/qa/tasks/rgw.py +++ b/qa/tasks/rgw.py @@ -69,10 +69,7 @@ def start_rgw(ctx, config, clients): if endpoint.cert: # add the ssl certificate path frontends += ' ssl_certificate={}'.format(endpoint.cert.certificate) - if ctx.rgw.frontend == 'civetweb': - frontends += ' port={}s'.format(endpoint.port) - else: - frontends += ' ssl_port={}'.format(endpoint.port) + frontends += ' ssl_port={}'.format(endpoint.port) else: frontends += ' port={}'.format(endpoint.port) @@ -370,7 +367,7 @@ def task(ctx, config): ctx.rgw.ec_data_pool = bool(config.pop('ec-data-pool', False)) ctx.rgw.erasure_code_profile = config.pop('erasure_code_profile', {}) ctx.rgw.cache_pools = bool(config.pop('cache-pools', False)) - ctx.rgw.frontend = config.pop('frontend', 'civetweb') + ctx.rgw.frontend = config.pop('frontend', 'beast') ctx.rgw.compression_type = config.pop('compression type', None) ctx.rgw.storage_classes = config.pop('storage classes', None) default_cert = config.pop('ssl certificate', None) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 032be4f0afe4..ed69b15fbef4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -878,31 +878,7 @@ endif(WITH_KVS) if(WITH_RADOSGW) add_subdirectory(libkmip) - - set(civetweb_common_files civetweb/src/civetweb.c) - add_library(civetweb_common_objs OBJECT ${civetweb_common_files}) - target_include_directories(civetweb_common_objs SYSTEM PRIVATE - "${CMAKE_SOURCE_DIR}/src/civetweb/include") - set_property(TARGET civetweb_common_objs - APPEND PROPERTY COMPILE_DEFINITIONS USE_IPV6=1) - if (LIBSSL_SONAME) - set_property(TARGET civetweb_common_objs - APPEND PROPERTY COMPILE_DEFINITIONS SSL_LIB="${LIBSSL_SONAME}") - set_property(TARGET civetweb_common_objs - APPEND PROPERTY COMPILE_DEFINITIONS CRYPTO_LIB="${LIBCRYPTO_SONAME}") - endif() - - if (OPENSSL_FOUND) - # Use cmake to determine openssl version, a TODO is to make - # civetweb itself do this based on openssl_api_compat strings - if (NOT (OPENSSL_VERSION VERSION_LESS "1.1")) - message(STATUS "Setting civetweb to use OPENSSL >= 1.1") - set_property(TARGET civetweb_common_objs - APPEND PROPERTY COMPILE_DEFINITIONS OPENSSL_API_1_1=1) - endif() - endif(OPENSSL_FOUND) add_subdirectory(rgw) - endif(WITH_RADOSGW) install(FILES diff --git a/src/civetweb b/src/civetweb deleted file mode 160000 index bb99e93da00c..000000000000 --- a/src/civetweb +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bb99e93da00c3fe8c6b6a98520fb17cf64710ce7 diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index 673f80c8a63c..2f8f1e8c9dc0 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -1,16 +1,3 @@ -set(civetweb_h - "${CMAKE_BINARY_DIR}/src/include/civetweb/civetweb.h") - -add_custom_command( - OUTPUT ${civetweb_h} - COMMAND ${CMAKE_COMMAND} -E make_directory - "${CMAKE_BINARY_DIR}/src/include/civetweb" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${CMAKE_SOURCE_DIR}/src/civetweb/include/civetweb.h" - ${civetweb_h} - DEPENDS "${CMAKE_SOURCE_DIR}/src/civetweb/include/civetweb.h" - COMMENT "keep civetweb.h up-to-date") - find_program(GPERF gperf) if(NOT GPERF) message(FATAL_ERROR "Can't find gperf") @@ -236,8 +223,7 @@ set(rgw_a_srcs rgw_usage.cc rgw_opa.cc rgw_sts.cc - rgw_rest_sts.cc - ${civetweb_h}) + rgw_rest_sts.cc) gperf_generate(${CMAKE_SOURCE_DIR}/src/rgw/rgw_iam_policy_keywords.gperf rgw_iam_policy_keywords.frag.cc) @@ -306,11 +292,7 @@ set(rgw_schedulers_srcs rgw_dmclock_scheduler_ctx.cc rgw_dmclock_sync_scheduler.cc) set(radosgw_srcs - rgw_loadgen_process.cc - rgw_civetweb.cc - rgw_civetweb_frontend.cc - rgw_civetweb_log.cc - ${civetweb_h}) + rgw_loadgen_process.cc) if (WITH_RADOSGW_FCGI_FRONTEND) list(APPEND radosgw_srcs rgw_fcgi_process.cc) endif() @@ -328,8 +310,7 @@ target_link_libraries(rgw_schedulers PUBLIC dmclock::dmclock) add_library(radosgw SHARED ${radosgw_srcs} ${rgw_a_srcs} rgw_main.cc - $ - $) + $) target_compile_definitions(radosgw PUBLIC "-DCLS_CLIENT_HIDE_IOCTX") target_include_directories(radosgw PUBLIC "${CMAKE_SOURCE_DIR}/src/dmclock/support/src") diff --git a/src/rgw/rgw_civetweb.cc b/src/rgw/rgw_civetweb.cc deleted file mode 100644 index 3607e679273a..000000000000 --- a/src/rgw/rgw_civetweb.cc +++ /dev/null @@ -1,248 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab ft=cpp - -#include -#include - -#include - -#include "civetweb/civetweb.h" -#include "rgw_civetweb.h" -#include "rgw_perf_counters.h" - - -#define dout_subsys ceph_subsys_rgw - -size_t RGWCivetWeb::write_data(const char *buf, const size_t len) -{ - size_t off = 0; - auto to_sent = len; - while (to_sent) { - const int ret = mg_write(conn, buf + off, to_sent); - if (ret < 0 || ! ret) { - /* According to the documentation of mg_write() it always returns -1 on - * error. The details aren't available, so we will just throw EIO. Same - * goes to 0 that is associated with writing to a closed connection. */ - throw rgw::io::Exception(EIO, std::system_category()); - } else { - off += static_cast(ret); - to_sent -= static_cast(ret); - } - } - return len; -} - -RGWCivetWeb::RGWCivetWeb(mg_connection* const conn) - : conn(conn), - explicit_keepalive(false), - explicit_conn_close(false), - got_eof_on_read(false), - txbuf(*this) -{ - sockaddr *lsa = mg_get_local_addr(conn); - switch(lsa->sa_family) { - case AF_INET: - port = ntohs(((struct sockaddr_in*)lsa)->sin_port); - break; - case AF_INET6: - port = ntohs(((struct sockaddr_in6*)lsa)->sin6_port); - break; - default: - port = -1; - } -} - -size_t RGWCivetWeb::read_data(char *buf, size_t len) -{ - size_t c; - int ret; - if (got_eof_on_read) { - return 0; - } - for (c = 0; c < len; c += ret) { - ret = mg_read(conn, buf+c, len-c); - if (ret < 0) { - throw rgw::io::Exception(EIO, std::system_category()); - } - if (!ret) { - got_eof_on_read = true; - break; - } - } - return c; -} - -void RGWCivetWeb::flush() -{ - txbuf.pubsync(); -} - -size_t RGWCivetWeb::complete_request() -{ - perfcounter->inc(l_rgw_qlen, -1); - perfcounter->inc(l_rgw_qactive, -1); - return 0; -} - -int RGWCivetWeb::init_env(CephContext *cct) -{ - env.init(cct); - const struct mg_request_info* info = mg_get_request_info(conn); - - if (! info) { - // request info is NULL; we have no info about the connection - return -EINVAL; - } - - for (int i = 0; i < info->num_headers; i++) { - const auto header = &info->http_headers[i]; - - if (header->name == nullptr || header->value==nullptr) { - lderr(cct) << "client supplied malformatted headers" << dendl; - return -EINVAL; - } - - const std::string_view name(header->name); - const auto& value = header->value; - - if (boost::algorithm::iequals(name, "content-length")) { - env.set("CONTENT_LENGTH", value); - continue; - } - if (boost::algorithm::iequals(name, "content-type")) { - env.set("CONTENT_TYPE", value); - continue; - } - if (boost::algorithm::iequals(name, "connection")) { - explicit_keepalive = boost::algorithm::iequals(value, "keep-alive"); - explicit_conn_close = boost::algorithm::iequals(value, "close"); - } - - static const std::string_view HTTP_{"HTTP_"}; - - char buf[name.size() + HTTP_.size() + 1]; - auto dest = std::copy(std::begin(HTTP_), std::end(HTTP_), buf); - for (auto src = name.begin(); src != name.end(); ++src, ++dest) { - if (*src == '-') { - *dest = '_'; - } else { - *dest = std::toupper(*src); - } - } - *dest = '\0'; - - env.set(buf, value); - } - - perfcounter->inc(l_rgw_qlen); - perfcounter->inc(l_rgw_qactive); - - env.set("REMOTE_ADDR", info->remote_addr); - env.set("REQUEST_METHOD", info->request_method); - env.set("HTTP_VERSION", info->http_version); - env.set("REQUEST_URI", info->request_uri); // get the full uri, we anyway handle abs uris later - env.set("SCRIPT_URI", info->local_uri); - if (info->query_string) { - env.set("QUERY_STRING", info->query_string); - } - if (info->remote_user) { - env.set("REMOTE_USER", info->remote_user); - } - - if (port <= 0) - lderr(cct) << "init_env: bug: invalid port number" << dendl; - char port_buf[16]; - snprintf(port_buf, sizeof(port_buf), "%d", port); - env.set("SERVER_PORT", port_buf); - if (info->is_ssl) { - env.set("SERVER_PORT_SECURE", port_buf); - } - return 0; -} - -size_t RGWCivetWeb::send_status(int status, const char *status_name) -{ - mg_set_http_status(conn, status); - - static constexpr size_t STATUS_BUF_SIZE = 128; - - char statusbuf[STATUS_BUF_SIZE]; - const auto statuslen = snprintf(statusbuf, sizeof(statusbuf), - "HTTP/1.1 %d %s\r\n", status, status_name); - - return txbuf.sputn(statusbuf, statuslen); -} - -size_t RGWCivetWeb::send_100_continue() -{ - const char HTTTP_100_CONTINUE[] = "HTTP/1.1 100 CONTINUE\r\n\r\n"; - const size_t sent = txbuf.sputn(HTTTP_100_CONTINUE, - sizeof(HTTTP_100_CONTINUE) - 1); - flush(); - return sent; -} - -size_t RGWCivetWeb::send_header(const std::string_view& name, - const std::string_view& value) -{ - static constexpr char HEADER_SEP[] = ": "; - static constexpr char HEADER_END[] = "\r\n"; - - size_t sent = 0; - - sent += txbuf.sputn(name.data(), name.length()); - sent += txbuf.sputn(HEADER_SEP, sizeof(HEADER_SEP) - 1); - sent += txbuf.sputn(value.data(), value.length()); - sent += txbuf.sputn(HEADER_END, sizeof(HEADER_END) - 1); - - return sent; -} - -size_t RGWCivetWeb::dump_date_header() -{ - char timestr[TIME_BUF_SIZE]; - - const time_t gtime = time(nullptr); - struct tm result; - struct tm const* const tmp = gmtime_r(>ime, &result); - - if (nullptr == tmp) { - return 0; - } - - if (! strftime(timestr, sizeof(timestr), - "Date: %a, %d %b %Y %H:%M:%S %Z\r\n", tmp)) { - return 0; - } - - return txbuf.sputn(timestr, strlen(timestr)); -} - -size_t RGWCivetWeb::complete_header() -{ - size_t sent = dump_date_header(); - - if (explicit_keepalive) { - constexpr char CONN_KEEP_ALIVE[] = "Connection: Keep-Alive\r\n"; - sent += txbuf.sputn(CONN_KEEP_ALIVE, sizeof(CONN_KEEP_ALIVE) - 1); - } else if (explicit_conn_close) { - constexpr char CONN_KEEP_CLOSE[] = "Connection: close\r\n"; - sent += txbuf.sputn(CONN_KEEP_CLOSE, sizeof(CONN_KEEP_CLOSE) - 1); - } - - static constexpr char HEADER_END[] = "\r\n"; - sent += txbuf.sputn(HEADER_END, sizeof(HEADER_END) - 1); - - flush(); - return sent; -} - -size_t RGWCivetWeb::send_content_length(uint64_t len) -{ - static constexpr size_t CONLEN_BUF_SIZE = 128; - - char sizebuf[CONLEN_BUF_SIZE]; - const auto sizelen = snprintf(sizebuf, sizeof(sizebuf), - "Content-Length: %" PRIu64 "\r\n", len); - return txbuf.sputn(sizebuf, sizelen); -} diff --git a/src/rgw/rgw_civetweb.h b/src/rgw/rgw_civetweb.h deleted file mode 100644 index 8288b9705f37..000000000000 --- a/src/rgw/rgw_civetweb.h +++ /dev/null @@ -1,59 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab ft=cpp - -#ifndef CEPH_RGW_MONGOOSE_H -#define CEPH_RGW_MONGOOSE_H -#define TIME_BUF_SIZE 128 - -#include "rgw_client_io.h" - - -struct mg_connection; - -class RGWCivetWeb : public rgw::io::RestfulClient, - public rgw::io::BuffererSink { - RGWEnv env; - mg_connection *conn; - - int port; - - bool explicit_keepalive; - bool explicit_conn_close; - bool got_eof_on_read; - - rgw::io::StaticOutputBufferer<> txbuf; - - size_t write_data(const char *buf, size_t len) override; - size_t read_data(char *buf, size_t len); - size_t dump_date_header(); - -public: - [[nodiscard]] int init_env(CephContext *cct) override; - - size_t send_status(int status, const char *status_name) override; - size_t send_100_continue() override; - size_t send_header(const std::string_view& name, - const std::string_view& value) override; - size_t send_content_length(uint64_t len) override; - size_t complete_header() override; - - size_t recv_body(char* buf, size_t max) override { - return read_data(buf, max); - } - - size_t send_body(const char* buf, size_t len) override { - return write_data(buf, len); - } - - size_t complete_request() override; - - void flush() override; - - RGWEnv& get_env() noexcept override { - return env; - } - - explicit RGWCivetWeb(mg_connection *_conn); -}; - -#endif diff --git a/src/rgw/rgw_civetweb_frontend.cc b/src/rgw/rgw_civetweb_frontend.cc deleted file mode 100644 index e03dc496ceb2..000000000000 --- a/src/rgw/rgw_civetweb_frontend.cc +++ /dev/null @@ -1,154 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab ft=cpp - -#include -#include -#include - -#include "rgw_frontend.h" -#include "rgw_client_io_filters.h" -#include "rgw_dmclock_sync_scheduler.h" - -#define dout_subsys ceph_subsys_rgw - -namespace dmc = rgw::dmclock; - -RGWCivetWebFrontend::RGWCivetWebFrontend(RGWProcessEnv& env, - RGWFrontendConfig *conf, - dmc::SchedulerCtx& sched_ctx) - : conf(conf), - ctx(nullptr), - env(env) -{ - - auto sched_t = dmc::get_scheduler_t(cct()); - switch(sched_t){ - case dmc::scheduler_t::none: [[fallthrough]]; - case dmc::scheduler_t::throttler: - break; - case dmc::scheduler_t::dmclock: - // TODO: keep track of server ready state and use that here civetweb - // internally tracks in the ctx the threads used and free, while it is - // expected with the current implementation that the threads waiting on the - // queue would still show up in the "used" queue, it might be a useful thing - // to make decisions on in the future. Also while reconfiguring we should - // probably set this to false - auto server_ready_f = []() -> bool { return true; }; - - scheduler.reset(new dmc::SyncScheduler(cct(), - std::ref(sched_ctx.get_dmc_client_counters()), - *sched_ctx.get_dmc_client_config(), - server_ready_f, - std::ref(dmc::SyncScheduler::handle_request_cb), - dmc::AtLimit::Reject)); - } - -} - -static int civetweb_callback(struct mg_connection* conn) -{ - const struct mg_request_info* const req_info = mg_get_request_info(conn); - return static_cast(req_info->user_data)->process(conn); -} - -int RGWCivetWebFrontend::process(struct mg_connection* const conn) -{ - /* Hold a read lock over access to env.store for reconfiguration. */ - std::shared_lock lock{env.mutex}; - - RGWCivetWeb cw_client(conn); - auto real_client_io = rgw::io::add_reordering( - rgw::io::add_buffering(dout_context, - rgw::io::add_chunking( - rgw::io::add_conlen_controlling( - &cw_client)))); - RGWRestfulIO client_io(dout_context, &real_client_io); - - RGWRequest req(env.store->get_new_req_id()); - int http_ret = 0; - ceph::coarse_real_clock::duration latency{}; - //assert (scheduler != nullptr); - int ret = process_request(env.store, env.rest, &req, env.uri_prefix, - *env.auth_registry, &client_io, env.olog, - null_yield, scheduler.get(), nullptr, &latency, &http_ret); - if (ret < 0) { - /* We don't really care about return code. */ - dout(20) << "process_request() returned " << ret << dendl; - } - - if (http_ret <= 0) { - /* Mark as processed. */ - return 1; - } - - return http_ret; -} - -int RGWCivetWebFrontend::run() -{ - auto& conf_map = conf->get_config_map(); - - set_conf_default(conf_map, "num_threads", - std::to_string(g_conf()->rgw_thread_pool_size)); - set_conf_default(conf_map, "decode_url", "no"); - set_conf_default(conf_map, "enable_keep_alive", "yes"); - set_conf_default(conf_map, "validate_http_method", "no"); - set_conf_default(conf_map, "canonicalize_url_path", "no"); - set_conf_default(conf_map, "enable_auth_domain_check", "no"); - set_conf_default(conf_map, "allow_unicode_in_urls", "yes"); - set_conf_default(conf_map, "request_timeout_ms", "65000"); - - std::string listening_ports; - // support multiple port= entries - auto range = conf_map.equal_range("port"); - for (auto p = range.first; p != range.second; ++p) { - std::string port_str = p->second; - // support port= entries with multiple values - std::replace(port_str.begin(), port_str.end(), '+', ','); - if (!listening_ports.empty()) { - listening_ports.append(1, ','); - } - listening_ports.append(port_str); - } - if (listening_ports.empty()) { - listening_ports = "80"; - } - conf_map.emplace("listening_ports", std::move(listening_ports)); - - /* Set run_as_user. This will cause civetweb to invoke setuid() and setgid() - * based on pw_uid and pw_gid obtained from pw_name. */ - std::string uid_string = g_ceph_context->get_set_uid_string(); - if (! uid_string.empty()) { - conf_map.emplace("run_as_user", std::move(uid_string)); - } - - /* Prepare options for CivetWeb. */ - const std::set rgw_opts = { "port", "prefix" }; - - std::vector options; - - for (const auto& pair : conf_map) { - if (! rgw_opts.count(pair.first)) { - /* CivetWeb doesn't understand configurables of the glue layer between - * it and RadosGW. We need to strip them out. Otherwise CivetWeb would - * signalise an error. */ - options.push_back(pair.first.c_str()); - options.push_back(pair.second.c_str()); - - dout(20) << "civetweb config: " << pair.first - << ": " << pair.second << dendl; - } - } - - options.push_back(nullptr); - /* Initialize the CivetWeb right now. */ - struct mg_callbacks cb; - // FIPS zeroization audit 20191115: this memset is not security related. - memset((void *)&cb, 0, sizeof(cb)); - cb.begin_request = civetweb_callback; - cb.log_message = rgw_civetweb_log_callback; - cb.log_access = rgw_civetweb_log_access_callback; - ctx = mg_start(&cb, this, options.data()); - - return ! ctx ? -EIO : 0; -} /* RGWCivetWebFrontend::run */ diff --git a/src/rgw/rgw_civetweb_log.cc b/src/rgw/rgw_civetweb_log.cc deleted file mode 100644 index 0d6c4ac12db7..000000000000 --- a/src/rgw/rgw_civetweb_log.cc +++ /dev/null @@ -1,24 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab ft=cpp - -#include "common/config.h" -#include "rgw_common.h" - -#include "civetweb/civetweb.h" -#include "rgw_crypt_sanitize.h" - -#define dout_subsys ceph_subsys_civetweb - - -#define dout_context g_ceph_context -int rgw_civetweb_log_callback(const struct mg_connection *conn, const char *buf) { - dout(0) << "civetweb: " << (void *)conn << ": " << rgw::crypt_sanitize::log_content(buf) << dendl; - return 0; -} - -int rgw_civetweb_log_access_callback(const struct mg_connection *conn, const char *buf) { - dout(1) << "civetweb: " << (void *)conn << ": " << rgw::crypt_sanitize::log_content(buf) << dendl; - return 0; -} - - diff --git a/src/rgw/rgw_civetweb_log.h b/src/rgw/rgw_civetweb_log.h deleted file mode 100644 index 4807c4930970..000000000000 --- a/src/rgw/rgw_civetweb_log.h +++ /dev/null @@ -1,10 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab ft=cpp - -#ifndef CEPH_RGW_CIVETWEB_LOG_H -#define CEPH_RGW_CIVETWEB_LOG_H - -int rgw_civetweb_log_callback(const struct mg_connection *conn, const char *buf); -int rgw_civetweb_log_access_callback(const struct mg_connection *conn, const char *buf); - -#endif diff --git a/src/rgw/rgw_frontend.h b/src/rgw/rgw_frontend.h index 6ba1448c929f..25899f96667d 100644 --- a/src/rgw/rgw_frontend.h +++ b/src/rgw/rgw_frontend.h @@ -13,9 +13,6 @@ #include "rgw_process.h" #include "rgw_realm_reloader.h" -#include "rgw_civetweb.h" -#include "rgw_civetweb_log.h" -#include "civetweb/civetweb.h" #include "rgw_auth_registry.h" #include "rgw_sal_rados.h" @@ -90,73 +87,6 @@ public: }; -struct RGWMongooseEnv : public RGWProcessEnv { - // every request holds a read lock, so we need to prioritize write locks to - // avoid starving pause_for_new_config() - static constexpr bool prioritize_write = true; - RWLock mutex; - - explicit RGWMongooseEnv(const RGWProcessEnv &env) - : RGWProcessEnv(env), - mutex("RGWCivetWebFrontend", false, true, prioritize_write) { - } -}; - - -class RGWCivetWebFrontend : public RGWFrontend { - RGWFrontendConfig* conf; - struct mg_context* ctx; - RGWMongooseEnv env; - - std::unique_ptr scheduler; - std::unique_ptr client_config; - - void set_conf_default(std::multimap& m, - const std::string& key, - const std::string& def_val) { - if (m.find(key) == std::end(m)) { - m.emplace(key, def_val); - } - } - - CephContext* cct() const { return env.store->ctx(); } -public: - RGWCivetWebFrontend(RGWProcessEnv& env, - RGWFrontendConfig *conf, - rgw::dmclock::SchedulerCtx& sched_ctx); - - int init() override { - return 0; - } - - int run() override; - - int process(struct mg_connection* conn); - - void stop() override { - if (ctx) { - mg_stop(ctx); - } - } - - void join() override { - return; - } - - void pause_for_new_config() override { - // block callbacks until unpause - env.mutex.get_write(); - } - - void unpause_with_new_config(rgw::sal::Store* const store, - rgw_auth_registry_ptr_t auth_registry) override { - env.store = store; - env.auth_registry = std::move(auth_registry); - // unpause callbacks - env.mutex.put_write(); - } -}; /* RGWCivetWebFrontend */ - class RGWProcessFrontend : public RGWFrontend { protected: RGWFrontendConfig* conf; diff --git a/src/rgw/rgw_http_client_curl.cc b/src/rgw/rgw_http_client_curl.cc index d243251a8a26..c11eacdd417a 100644 --- a/src/rgw/rgw_http_client_curl.cc +++ b/src/rgw/rgw_http_client_curl.cc @@ -82,7 +82,7 @@ void init_ssl() { bool fe_inits_ssl(boost::optional m, long& curl_global_flags){ if (m) { for (const auto& kv: *m){ - if (kv.first == "civetweb" || kv.first == "beast"){ + if (kv.first == "beast"){ std::string cert; kv.second->get_val("ssl_certificate","", &cert); if (!cert.empty()){ diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index b684021a7a13..9c7b3fc80408 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -225,12 +225,12 @@ int radosgw_Main(int argc, const char **argv) multimap fe_map; list configs; if (frontends.empty()) { - frontends.push_back("civetweb"); + frontends.push_back("beast"); } for (list::iterator iter = frontends.begin(); iter != frontends.end(); ++iter) { string& f = *iter; - if (f.find("civetweb") != string::npos || f.find("beast") != string::npos) { + if (f.find("beast") != string::npos) { if (f.find("port") != string::npos) { // check for the most common ws problems if ((f.find("port=") == string::npos) || @@ -559,19 +559,7 @@ int radosgw_Main(int argc, const char **argv) RGWFrontend *fe = NULL; - if (framework == "civetweb" || framework == "mongoose") { - lderr(cct.get()) << "IMPORTANT: the civetweb frontend is now deprecated " - "and will be removed in a future release" << dendl; - framework = "civetweb"; - std::string uri_prefix; - config->get_val("prefix", "", &uri_prefix); - - RGWProcessEnv env = { store, &rest, olog, 0, uri_prefix, auth_registry }; - //TODO: move all of scheduler initializations to frontends? - - fe = new RGWCivetWebFrontend(env, config, sched_ctx); - } - else if (framework == "loadgen") { + if (framework == "loadgen") { int port; config->get_val("port", 80, &port); std::string uri_prefix;