From bf15e94637c516df251ceb290be61f0b23c96b56 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Mon, 30 Jun 2025 16:54:46 -0400 Subject: [PATCH] rgw/datalog: Manage and shutdown tasks properly This is slightly ugly but good enough for now. Make sure we can block when shutting down background tasks. Remove a few `driver` parameters that are unused. This lets us simplify the IAM Policy and Lua tests and not construct stores we never use. (Which is good since we aren't running them under a cluster.) Signed-off-by: Adam C. Emerson (cherry picked from commit 3def99eec5df353a0fb34be79d9e98a08eb05985) Conflicts: src/rgw/driver/rados/rgw_service.cc src/rgw/rgw_sal.h src/rgw/rgw_sal.cc - `#ifdef` changes src/test/rgw/test_rgw_iam_policy.cc src/test/rgw/test_rgw_lua.cc - SAL renaming Signed-off-by: Adam C. Emerson --- src/rgw/driver/rados/rgw_datalog.cc | 124 +++++++++----- src/rgw/driver/rados/rgw_datalog.h | 25 +-- src/rgw/driver/rados/rgw_log_backing.cc | 22 ++- src/rgw/driver/rados/rgw_log_backing.h | 17 +- src/rgw/driver/rados/rgw_sal_rados.cc | 37 ++-- src/rgw/driver/rados/rgw_sal_rados.h | 15 +- src/rgw/driver/rados/rgw_service.cc | 2 +- src/rgw/driver/rados/rgw_service.h | 2 +- src/rgw/rgw_appmain.cc | 2 +- src/rgw/rgw_lua_background.cc | 4 +- src/rgw/rgw_lua_background.h | 10 +- src/rgw/rgw_lua_request.cc | 1 - src/rgw/rgw_lua_request.h | 2 +- src/rgw/rgw_op.cc | 5 +- src/rgw/rgw_op.h | 3 +- src/rgw/rgw_process.cc | 6 +- src/rgw/rgw_process_env.h | 2 + src/rgw/rgw_rest.cc | 2 +- src/rgw/rgw_sal.cc | 32 +++- src/rgw/rgw_sal.h | 3 + src/test/rgw/test_datalog.cc | 20 +-- src/test/rgw/test_rgw_iam_policy.cc | 62 +++++-- src/test/rgw/test_rgw_lua.cc | 215 +++++++++++------------- 23 files changed, 340 insertions(+), 273 deletions(-) diff --git a/src/rgw/driver/rados/rgw_datalog.cc b/src/rgw/driver/rados/rgw_datalog.cc index 6c0464dbf88..8fe75e8a59a 100644 --- a/src/rgw/driver/rados/rgw_datalog.cc +++ b/src/rgw/driver/rados/rgw_datalog.cc @@ -132,7 +132,7 @@ class RGWDataChangesOmap final : public RGWDataChangesBE { std::vector oids; public: - RGWDataChangesOmap(neorados::RADOS& r, + RGWDataChangesOmap(neorados::RADOS r, neorados::IOContext loc, RGWDataChangesLog& datalog, uint64_t gen_id, @@ -273,7 +273,7 @@ class RGWDataChangesFIFO final : public RGWDataChangesBE { tiny_vector fifos; public: - RGWDataChangesFIFO(neorados::RADOS& r, + RGWDataChangesFIFO(neorados::RADOS r, neorados::IOContext loc, RGWDataChangesLog& datalog, uint64_t gen_id, @@ -504,12 +504,12 @@ RGWDataChangesLog::start(const DoutPrefixProvider *dpp, } if (renew) { - asio::co_spawn( + renew_future = asio::co_spawn( renew_strand, - renew_run(shared_from_this()), + renew_run(), asio::bind_cancellation_slot(renew_signal.slot(), asio::bind_executor(renew_strand, - asio::detached))); + asio::use_future))); } if (watch) { // Establish watch here so we won't be 'started up' until we're watching. @@ -519,22 +519,22 @@ RGWDataChangesLog::start(const DoutPrefixProvider *dpp, throw sys::system_error{ENOTCONN, sys::generic_category(), "Unable to establish recovery watch!"}; } - asio::co_spawn( + watch_future = asio::co_spawn( watch_strand, - watch_loop(shared_from_this()), + watch_loop(), asio::bind_cancellation_slot(watch_signal.slot(), asio::bind_executor(watch_strand, - asio::detached))); + asio::use_future))); } if (recovery) { // Recovery can run concurrent with normal operation, so we don't // have to block startup while we do all that I/O. - asio::co_spawn( + recovery_future = asio::co_spawn( recovery_strand, - recover(dpp, shared_from_this()), + recover(dpp), asio::bind_cancellation_slot(recovery_signal.slot(), asio::bind_executor(recovery_strand, - asio::detached))); + asio::use_future))); } co_return; } @@ -661,7 +661,7 @@ RGWDataChangesLog::process_notification(const DoutPrefixProvider* dpp, } asio::awaitable -RGWDataChangesLog::watch_loop(std::shared_ptr) +RGWDataChangesLog::watch_loop() { const DoutPrefix dp(cct, dout_subsys, "rgw data changes log: "); const auto oid = get_sem_set_oid(0); @@ -1246,7 +1246,9 @@ bool RGWDataChangesLog::going_down() const return down_flag; } -asio::awaitable RGWDataChangesLog::shutdown() { +// Now, if we had an awaitable future… +asio::awaitable RGWDataChangesLog::async_shutdown() +{ DoutPrefix dp{cct, ceph_subsys_rgw, "Datalog Shutdown"}; if (down_flag) { co_return; @@ -1272,15 +1274,77 @@ asio::awaitable RGWDataChangesLog::shutdown() { if (watchcookie && rados->check_watch(watchcookie)) { auto wc = watchcookie; watchcookie = 0; - co_await rados->unwatch(wc, loc, asio::use_awaitable); + try { + co_await rados->unwatch(wc, loc, asio::use_awaitable); + } catch (const std::exception& e) { + ldpp_dout(&dp, 2) + << "RGWDataChangesLog::async_shutdown: unwatch failed: " << e.what() + << dendl; + } } co_return; } -asio::awaitable RGWDataChangesLog::shutdown_or_timeout() { - using namespace asio::experimental::awaitable_operators; - asio::steady_timer t(co_await asio::this_coro::executor, 3s); - co_await (shutdown() || t.async_wait(asio::use_awaitable)); +void RGWDataChangesLog::blocking_shutdown() +{ + DoutPrefix dp{cct, ceph_subsys_rgw, "Datalog Shutdown"}; + if (down_flag) { + return; + } + down_flag = true; + if (ran_background) { + renew_stop(); + // Revisit this later + asio::dispatch(renew_strand, + [this]() { + renew_signal.emit(asio::cancellation_type::terminal); + }); + try { + renew_future.wait(); + } catch (const std::future_error& e) { + if (e.code() != std::future_errc::no_state) { + throw; + } + } + asio::dispatch(recovery_strand, + [this]() { + recovery_signal.emit(asio::cancellation_type::terminal); + }); + try { + recovery_future.wait(); + } catch (const std::future_error& e) { + if (e.code() != std::future_errc::no_state) { + throw; + } + } + asio::dispatch(watch_strand, + [this]() { + watch_signal.emit(asio::cancellation_type::terminal); + }); + try { + watch_future.wait(); + } catch (const std::future_error& e) { + if (e.code() != std::future_errc::no_state) { + throw; + } + } + if (watchcookie && rados->check_watch(watchcookie)) { + auto wc = watchcookie; + watchcookie = 0; + try { + rados->unwatch(wc, loc, async::use_blocked); + } catch (const std::exception& e) { + ldpp_dout(&dp, 2) + << "RGWDataChangesLog::blocking_shutdown: unwatch failed: " << e.what() + << dendl; + } + } + } + if (bes) { + bes->shutdown(); + bes.reset(); + } + return; } RGWDataChangesLog::~RGWDataChangesLog() { @@ -1290,26 +1354,7 @@ RGWDataChangesLog::~RGWDataChangesLog() { } } -void RGWDataChangesLog::blocking_shutdown() { - if (!down_flag) { - try { - asio::co_spawn(rados->get_io_context(), - shutdown_or_timeout(), - async::use_blocked); - } catch (const sys::system_error& e) { - lderr(cct) << __PRETTY_FUNCTION__ - << ": Failed to shutting down: " << e.what() - << dendl; - } catch (const std::exception& e) { - lderr(cct) << __PRETTY_FUNCTION__ - << ": Failed to shutting down: " << e.what() - << dendl; - } - } -} - -asio::awaitable RGWDataChangesLog::renew_run( - std::shared_ptr) { +asio::awaitable RGWDataChangesLog::renew_run() { static constexpr auto runs_per_prune = 150; auto run = 0; renew_timer.emplace(co_await asio::this_coro::executor); @@ -1583,8 +1628,7 @@ RGWDataChangesLog::recover_shard(const DoutPrefixProvider* dpp, int index) } asio::awaitable RGWDataChangesLog::recover( - const DoutPrefixProvider* dpp, - std::shared_ptr) + const DoutPrefixProvider* dpp) { co_await asio::co_spawn( recovery_strand, diff --git a/src/rgw/driver/rados/rgw_datalog.h b/src/rgw/driver/rados/rgw_datalog.h index d47e4e84eda..ae013e2fdef 100644 --- a/src/rgw/driver/rados/rgw_datalog.h +++ b/src/rgw/driver/rados/rgw_datalog.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #include #include @@ -14,6 +15,7 @@ #include #include +#include #include #include @@ -206,7 +208,7 @@ class DataLogBackends final std::mutex m; RGWDataChangesLog& datalog; - DataLogBackends(neorados::RADOS& rados, + DataLogBackends(neorados::RADOS rados, const neorados::Object oid, const neorados::IOContext& loc, fu2::unique_function { }; } -class RGWDataChangesLog - : public std::enable_shared_from_this { +class RGWDataChangesLog { friend class DataLogTestBase; friend DataLogBackends; CephContext *cct; @@ -366,10 +367,13 @@ class RGWDataChangesLog using strand_t = asio::strand; strand_t renew_strand{executor}; asio::cancellation_signal renew_signal = asio::cancellation_signal(); + std::future renew_future; strand_t watch_strand{executor}; asio::cancellation_signal watch_signal = asio::cancellation_signal(); + std::future watch_future; strand_t recovery_strand{executor}; asio::cancellation_signal recovery_signal = asio::cancellation_signal(); + std::future recovery_future; ceph::mono_time last_recovery = ceph::mono_clock::zero(); @@ -414,8 +418,7 @@ class RGWDataChangesLog ceph::real_time expiration); std::optional renew_timer; - asio::awaitable renew_run( - std::shared_ptr renew_signal); + asio::awaitable renew_run(); void renew_stop(); std::function process_notification(const DoutPrefixProvider* dpp, std::string_view oid); - asio::awaitable watch_loop(std::shared_ptr); + asio::awaitable watch_loop(); int choose_oid(const rgw_bucket_shard& bs); asio::awaitable add_entry(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, @@ -523,10 +526,8 @@ public: ceph::mono_time fetch_time, bc::flat_map&& semcount); asio::awaitable recover_shard(const DoutPrefixProvider* dpp, int index); - asio::awaitable recover(const DoutPrefixProvider* dpp, - std::shared_ptr); - asio::awaitable shutdown(); - asio::awaitable shutdown_or_timeout(); + asio::awaitable recover(const DoutPrefixProvider* dpp); + asio::awaitable async_shutdown(); void blocking_shutdown(); asio::awaitable admin_sem_list(std::optional req_shard, @@ -540,7 +541,7 @@ public: class RGWDataChangesBE : public boost::intrusive_ref_counter { protected: - neorados::RADOS& r; + neorados::RADOS r; neorados::IOContext loc; RGWDataChangesLog& datalog; @@ -555,7 +556,7 @@ public: const uint64_t gen_id; - RGWDataChangesBE(neorados::RADOS& r, + RGWDataChangesBE(neorados::RADOS r, neorados::IOContext loc, RGWDataChangesLog& datalog, uint64_t gen_id) diff --git a/src/rgw/driver/rados/rgw_log_backing.cc b/src/rgw/driver/rados/rgw_log_backing.cc index 0ea4ff16ddb..8e3442d3e82 100644 --- a/src/rgw/driver/rados/rgw_log_backing.cc +++ b/src/rgw/driver/rados/rgw_log_backing.cc @@ -52,7 +52,7 @@ inline std::ostream& operator <<(std::ostream& m, const shard_check& t) { namespace { /// Return the shard type, and a bool to see whether it has entries. asio::awaitable -probe_shard(const DoutPrefixProvider* dpp, neorados::RADOS& rados, +probe_shard(const DoutPrefixProvider* dpp, neorados::RADOS rados, const neorados::Object& obj, const neorados::IOContext& loc, bool& fifo_unsupported) { @@ -98,7 +98,7 @@ probe_shard(const DoutPrefixProvider* dpp, neorados::RADOS& rados, } asio::awaitable handle_dne(const DoutPrefixProvider *dpp, - neorados::RADOS& rados, + neorados::RADOS rados, const neorados::Object& obj, const neorados::IOContext& loc, log_type def, @@ -127,7 +127,7 @@ asio::awaitable handle_dne(const DoutPrefixProvider *dpp, asio::awaitable log_backing_type(const DoutPrefixProvider* dpp, - neorados::RADOS& rados, + neorados::RADOS rados, const neorados::IOContext& loc, log_type def, int shards, @@ -167,7 +167,7 @@ log_backing_type(const DoutPrefixProvider* dpp, asio::awaitable log_remove( const DoutPrefixProvider *dpp, - neorados::RADOS& rados, + neorados::RADOS rados, const neorados::IOContext& loc, int shards, const fu2::unique_function& get_oid, @@ -224,16 +224,26 @@ asio::awaitable log_remove( co_return; } -logback_generations::~logback_generations() { +void logback_generations::shutdown() { if (watchcookie > 0) { auto cct = rados.cct(); sys::error_code ec; - rados.unwatch(watchcookie, loc, asio::detached); + rados.unwatch(watchcookie, loc, async::use_blocked[ec]); if (ec) { lderr(cct) << __PRETTY_FUNCTION__ << ":" << __LINE__ << ": failed unwatching oid=" << oid << ", " << ec.message() << dendl; } + watchcookie = 0; + } +} + + +logback_generations::~logback_generations() { + auto cct = rados.cct(); + if (watchcookie > 0) { + lderr(cct) << __PRETTY_FUNCTION__ << ":" << __LINE__ + << ": logback_generations destroyed without shutdown." << dendl; } } diff --git a/src/rgw/driver/rados/rgw_log_backing.h b/src/rgw/driver/rados/rgw_log_backing.h index 7d5ffee150e..04360f9d80a 100644 --- a/src/rgw/driver/rados/rgw_log_backing.h +++ b/src/rgw/driver/rados/rgw_log_backing.h @@ -74,7 +74,7 @@ inline std::ostream& operator <<(std::ostream& m, const log_type& t) { /// Look over the shards in a log and determine the type. asio::awaitable log_backing_type(const DoutPrefixProvider* dpp, - neorados::RADOS& rados, + neorados::RADOS rados, const neorados::IOContext& loc, log_type def, int shards, @@ -83,7 +83,7 @@ log_backing_type(const DoutPrefixProvider* dpp, /// Remove all log shards and associated parts of fifos. asio::awaitable log_remove( const DoutPrefixProvider *dpp, - neorados::RADOS& rados, + neorados::RADOS rados, const neorados::IOContext& loc, int shards, const fu2::unique_function& get_oid, @@ -121,10 +121,10 @@ public: using entries_t = container::flat_map; protected: - neorados::RADOS& rados; + neorados::RADOS rados; neorados::IOContext loc; logback_generations( - neorados::RADOS& rados, + neorados::RADOS rados, neorados::Object oid, neorados::IOContext loc, fu2::unique_function get_oid, @@ -183,7 +183,7 @@ public: template static asio::awaitable> init( const DoutPrefixProvider *dpp, - neorados::RADOS& r_, + neorados::RADOS r_, const neorados::Object& oid_, const neorados::IOContext& loc_, fu2::unique_function&& get_oid_, @@ -225,6 +225,9 @@ public: /// /// @param new_tail Lowest non-empty generation virtual void handle_empty_to(uint64_t new_tail) = 0; + + /// If you override this, call the superclass method *at the end*. + virtual void shutdown(); }; inline std::string gencursor(uint64_t gen_id, std::string_view cursor) { @@ -252,7 +255,7 @@ cursorgen(std::optional cursor_) { } class LazyFIFO { - neorados::RADOS& r; + neorados::RADOS r; const std::string oid; const neorados::IOContext loc; std::mutex m; @@ -299,7 +302,7 @@ class LazyFIFO { public: - LazyFIFO(neorados::RADOS& r, std::string oid, neorados::IOContext loc) + LazyFIFO(neorados::RADOS r, std::string oid, neorados::IOContext loc) : r(r), oid(std::move(oid)), loc(std::move(loc)) {} asio::awaitable push(const DoutPrefixProvider *dpp, diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index 589b9d0dfe0..9563d452914 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -2268,25 +2268,12 @@ int RadosStore::get_raw_chunk_size(const DoutPrefixProvider* dpp, const rgw_raw_ return rados->get_max_chunk_size(obj.pool, chunk_size, dpp); } -int RadosStore::init_neorados(const DoutPrefixProvider* dpp) { - if (!neorados) try { - neorados = neorados::RADOS::make_with_cct(dpp->get_cct(), io_context, - ceph::async::use_blocked); - } catch (const boost::system::system_error& e) { - ldpp_dout(dpp, 0) << "ERROR: creating neorados handle failed: " - << e.what() << dendl; - return ceph::from_error_code(e.code()); - } - return 0; -} - int RadosStore::initialize(CephContext *cct, const DoutPrefixProvider *dpp) { std::unique_ptr zg = std::make_unique(this, svc()->zone->get_zonegroup()); zone = make_unique(this, std::move(zg)); - - return init_neorados(dpp); + return 0; } int RadosStore::log_usage(const DoutPrefixProvider *dpp, map& usage_info, optional_yield y) @@ -5445,20 +5432,17 @@ int RadosRole::delete_obj(const DoutPrefixProvider *dpp, optional_yield y) extern "C" { - void* newRadosStore(void* io_context, void* dpp_) +void* newRadosStore(void* io_context_, CephContext* cct) { - auto dpp = static_cast(dpp_); - rgw::sal::RadosStore* store = new rgw::sal::RadosStore( - *static_cast(io_context)); + auto& io_context = *static_cast(io_context_); + ceph_assert(!io_context.stopped()); + auto neorados = make_neorados(cct, io_context); + if (!neorados || !*neorados) { + return nullptr; + } + rgw::sal::RadosStore* store = nullptr; + store = new rgw::sal::RadosStore(*neorados); if (store) { - int ret = store->init_neorados(dpp); - if (ret < 0) { - ldpp_dout(dpp, 0) << "ERROR: failed to initialize neorados (ret=" << cpp_strerror(-ret) << ")" << dendl; - delete store; - store = nullptr; - return store; - } - RGWRados* rados = new RGWRados(); if (!rados) { @@ -5471,5 +5455,4 @@ extern "C" { return store; } - } diff --git a/src/rgw/driver/rados/rgw_sal_rados.h b/src/rgw/driver/rados/rgw_sal_rados.h index 7f9602f9355..ecfb4ba8c43 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.h +++ b/src/rgw/driver/rados/rgw_sal_rados.h @@ -120,22 +120,21 @@ class RadosZone : public StoreZone { class RadosStore : public StoreDriver { private: - boost::asio::io_context& io_context; + neorados::RADOS neorados; RGWRados* rados; RGWUserCtl* user_ctl; std::unique_ptr zone; - std::optional neorados; std::string topics_oid(const std::string& tenant) const; public: - RadosStore(boost::asio::io_context& io_context) - : io_context(io_context), rados(nullptr) { - } + RadosStore(neorados::RADOS neorados) + : neorados(neorados), rados(nullptr) { + ceph_assert(neorados); + } ~RadosStore() { delete rados; } - int init_neorados(const DoutPrefixProvider* dpp); virtual int initialize(CephContext *cct, const DoutPrefixProvider *dpp) override; virtual const std::string get_name() const override { return "rados"; @@ -446,8 +445,8 @@ class RadosStore : public StoreDriver { void setRados(RGWRados * st) { rados = st; } RGWRados* getRados(void) { return rados; } - boost::asio::io_context& get_io_context() { return io_context; } - neorados::RADOS& get_neorados() { return *neorados; } + boost::asio::io_context& get_io_context() { return neorados.get_io_context(); } + neorados::RADOS& get_neorados() { return neorados; } RGWServices* svc() { return &rados->svc; } const RGWServices* svc() const { return &rados->svc; } diff --git a/src/rgw/driver/rados/rgw_service.cc b/src/rgw/driver/rados/rgw_service.cc index 9e34cbf00f1..f33e46ff487 100644 --- a/src/rgw/driver/rados/rgw_service.cc +++ b/src/rgw/driver/rados/rgw_service.cc @@ -62,7 +62,7 @@ int RGWServices_Def::init(CephContext *cct, bilog_rados = std::make_unique(cct); cls = std::make_unique(cct); config_key_rados = std::make_unique(cct); - datalog_rados = std::make_shared(driver); + datalog_rados = std::make_unique(driver); mdlog = std::make_unique(cct, run_sync); notify = std::make_unique(cct); zone = std::make_unique(cct); diff --git a/src/rgw/driver/rados/rgw_service.h b/src/rgw/driver/rados/rgw_service.h index 3d361351946..c9cb71c3e30 100644 --- a/src/rgw/driver/rados/rgw_service.h +++ b/src/rgw/driver/rados/rgw_service.h @@ -98,7 +98,7 @@ struct RGWServices_Def std::unique_ptr sysobj_core; std::unique_ptr sysobj_cache; std::unique_ptr user_rados; - std::shared_ptr datalog_rados; + std::unique_ptr datalog_rados; std::unique_ptr async_processor; RGWServices_Def(); diff --git a/src/rgw/rgw_appmain.cc b/src/rgw/rgw_appmain.cc index 4a2142a7951..07561ca55f6 100644 --- a/src/rgw/rgw_appmain.cc +++ b/src/rgw/rgw_appmain.cc @@ -583,7 +583,7 @@ void rgw::AppMain::init_lua() env.lua.manager = env.driver->get_lua_manager(install_dir); if (driver->get_name() == "rados") { /* Supported for only RadosStore */ lua_background = std::make_unique< - rgw::lua::Background>(driver, dpp->get_cct(), env.lua.manager.get()); + rgw::lua::Background>(dpp->get_cct(), env.lua.manager.get()); lua_background->start(); env.lua.background = lua_background.get(); static_cast(env.lua.manager.get())->watch_reload(dpp); diff --git a/src/rgw/rgw_lua_background.cc b/src/rgw/rgw_lua_background.cc index 0b462f9c6e3..5027dcf8d29 100644 --- a/src/rgw/rgw_lua_background.cc +++ b/src/rgw/rgw_lua_background.cc @@ -56,7 +56,7 @@ int RGWTable::increment_by(lua_State* L) { return 0; } -Background::Background(rgw::sal::Driver* _driver, +Background::Background( CephContext* _cct, rgw::sal::LuaManager* _lua_manager, int _execute_interval) : @@ -93,7 +93,7 @@ void Background::pause() { cond.notify_all(); } -void Background::resume(rgw::sal::Driver* driver) { +void Background::resume(rgw::sal::Driver*) { paused = false; cond.notify_all(); } diff --git a/src/rgw/rgw_lua_background.h b/src/rgw/rgw_lua_background.h index f06ca491eb2..8745b7f3912 100644 --- a/src/rgw/rgw_lua_background.h +++ b/src/rgw/rgw_lua_background.h @@ -158,10 +158,9 @@ private: std::unique_ptr initialize_lguard_state(); public: - Background(rgw::sal::Driver* _driver, - CephContext* _cct, - rgw::sal::LuaManager* _lua_manager, - int _execute_interval = INIT_EXECUTE_INTERVAL); + Background(CephContext* _cct, + rgw::sal::LuaManager* _lua_manager, + int _execute_interval = INIT_EXECUTE_INTERVAL); ~Background() override = default; void start(); @@ -177,7 +176,8 @@ private: // update the manager after void set_manager(rgw::sal::LuaManager* _lua_manager); void pause() override; - void resume(rgw::sal::Driver* _driver) override; + // Does not actually use `Driver` argument. + void resume(rgw::sal::Driver*) override; }; } //namespace rgw::lua diff --git a/src/rgw/rgw_lua_request.cc b/src/rgw/rgw_lua_request.cc index 8d7f7281b96..f4726bb0db1 100644 --- a/src/rgw/rgw_lua_request.cc +++ b/src/rgw/rgw_lua_request.cc @@ -782,7 +782,6 @@ void create_top_metatable(lua_State* L, req_state* s, const char* op_name) { } int execute( - rgw::sal::Driver* driver, RGWREST* rest, OpsLogSink* olog, req_state* s, diff --git a/src/rgw/rgw_lua_request.h b/src/rgw/rgw_lua_request.h index 7c85ac9cd98..911c660f2c6 100644 --- a/src/rgw/rgw_lua_request.h +++ b/src/rgw/rgw_lua_request.h @@ -8,6 +8,7 @@ struct lua_State; class req_state; class RGWREST; class OpsLogSink; +class RGWOp; namespace rgw::lua::request { @@ -16,7 +17,6 @@ void create_top_metatable(lua_State* L, req_state* s, const char* op_name); // execute a lua script in the Request context int execute( - rgw::sal::Driver* driver, RGWREST* rest, OpsLogSink* olog, req_state *s, diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 8587bc27379..e8ce0cb17eb 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -879,8 +879,7 @@ static void rgw_add_grant_to_iam_environment(rgw::IAM::Environment& e, req_state } } -void rgw_build_iam_environment(rgw::sal::Driver* driver, - req_state* s) +void rgw_build_iam_environment(req_state* s) { const auto& m = s->info.env->get_map(); auto t = ceph::real_clock::now(); @@ -8615,7 +8614,7 @@ int RGWHandler::do_init_permissions(const DoutPrefixProvider *dpp, optional_yiel return ret==-ENODATA ? -EACCES : ret; } - rgw_build_iam_environment(driver, s); + rgw_build_iam_environment(s); return ret; } diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index ffddbe4c4e7..d7f206cea8a 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -2167,8 +2167,7 @@ extern int rgw_build_bucket_policies(const DoutPrefixProvider *dpp, rgw::sal::Dr req_state* s, optional_yield y); extern int rgw_build_object_policies(const DoutPrefixProvider *dpp, rgw::sal::Driver* driver, req_state *s, bool prefetch_data, optional_yield y); -extern void rgw_build_iam_environment(rgw::sal::Driver* driver, - req_state* s); +extern void rgw_build_iam_environment(req_state* s); inline int get_system_versioning_params(req_state *s, uint64_t *olh_epoch, diff --git a/src/rgw/rgw_process.cc b/src/rgw/rgw_process.cc index c0c34cebb66..d23e9ba3886 100644 --- a/src/rgw/rgw_process.cc +++ b/src/rgw/rgw_process.cc @@ -344,8 +344,7 @@ int process_request(const RGWProcessEnv& penv, "WARNING: failed to execute pre request script. " "error: " << rc << dendl; } else { - rc = rgw::lua::request::execute(driver, rest, penv.olog.get(), s, op, - script); + rc = rgw::lua::request::execute(rest, penv.olog.get(), s, op, script); if (rc < 0) { ldpp_dout(op, 5) << "WARNING: failed to execute pre request script. " @@ -443,8 +442,7 @@ done: "WARNING: failed to read post request script. " "error: " << rc << dendl; } else { - rc = rgw::lua::request::execute(driver, rest, penv.olog.get(), s, op, - script); + rc = rgw::lua::request::execute(rest, penv.olog.get(), s, op, script); if (rc < 0) { ldpp_dout(op, 5) << "WARNING: failed to execute post request script. " diff --git a/src/rgw/rgw_process_env.h b/src/rgw/rgw_process_env.h index 07eff0d7b97..201008c733d 100644 --- a/src/rgw/rgw_process_env.h +++ b/src/rgw/rgw_process_env.h @@ -5,6 +5,8 @@ #include +#include "rgw_auth_registry.h" + class ActiveRateLimiter; class OpsLogSink; class RGWREST; diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index 0592d66e3c1..a5bf94fedc8 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -1885,7 +1885,7 @@ static http_op op_from_method(const char *method) int RGWHandler_REST::init_permissions(RGWOp* op, optional_yield y) { if (op->get_type() == RGW_OP_CREATE_BUCKET) { - rgw_build_iam_environment(driver, s); + rgw_build_iam_environment(s); return 0; } diff --git a/src/rgw/rgw_sal.cc b/src/rgw/rgw_sal.cc index a3646c296c8..ebf9220510a 100644 --- a/src/rgw/rgw_sal.cc +++ b/src/rgw/rgw_sal.cc @@ -13,15 +13,17 @@ * */ +#include + #include #include -#include #include -#include #include "common/errno.h" //#include "common/dout.h" +#include "common/async/blocked_completion.h" + #include "rgw_sal.h" #include "rgw_sal_rados.h" #include "driver/rados/config/store.h" @@ -48,7 +50,7 @@ //#define dout_context g_ceph_context extern "C" { -extern rgw::sal::Driver* newRadosStore(void* io_context, const void* dpp); +extern rgw::sal::Driver* newRadosStore(void* io_context, CephContext* cct); #ifdef WITH_RADOSGW_DBSTORE extern rgw::sal::Driver* newDBStore(CephContext *cct); #endif @@ -67,6 +69,20 @@ extern rgw::sal::Driver* newD4NFilter(rgw::sal::Driver* next, boost::asio::io_co #endif } + +std::optional +make_neorados(CephContext* cct, boost::asio::io_context& io_context) { + try { + auto neorados = neorados::RADOS::make_with_cct(cct, io_context, + ceph::async::use_blocked); + return neorados; + } catch (const std::exception& e) { + ldout(cct, 0) << "Failed constructing neroados handle: " << e.what() + << dendl; + } + return std::nullopt; +} + rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider* dpp, CephContext* cct, const Config& cfg, @@ -87,7 +103,7 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider* rgw::sal::Driver* driver{nullptr}; if (cfg.store_name.compare("rados") == 0) { - driver = newRadosStore(&io_context, dpp); + driver = newRadosStore(&io_context, cct); RGWRados* rados = static_cast(driver)->getRados(); if ((*rados).set_use_cache(use_cache) @@ -114,7 +130,11 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider* } } else if (cfg.store_name.compare("d3n") == 0) { - driver = new rgw::sal::RadosStore(io_context); + auto neorados = make_neorados(cct, io_context); + if (!neorados) { + return nullptr; + } + driver = new rgw::sal::RadosStore(*neorados); RGWRados* rados = new D3nRGWDataCache; dynamic_cast(driver)->setRados(rados); rados->set_store(static_cast(driver)); @@ -241,7 +261,7 @@ rgw::sal::Driver* DriverManager::init_raw_storage_provider(const DoutPrefixProvi { rgw::sal::Driver* driver = nullptr; if (cfg.store_name.compare("rados") == 0) { - driver = newRadosStore(&io_context, dpp); + driver = newRadosStore(&io_context, cct); RGWRados* rados = static_cast(driver)->getRados(); rados->set_context(cct); diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 776c151349b..0f2571b0fac 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -2001,4 +2001,7 @@ public: }; +std::optional +make_neorados(CephContext* cct, boost::asio::io_context& io_context); + /** @} */ diff --git a/src/test/rgw/test_datalog.cc b/src/test/rgw/test_datalog.cc index cc873896ca8..14b232b8034 100644 --- a/src/test/rgw/test_datalog.cc +++ b/src/test/rgw/test_datalog.cc @@ -60,12 +60,12 @@ private: boost::asio::use_awaitable); } - virtual asio::awaitable> + virtual asio::awaitable> create_datalog() = 0; protected: - std::shared_ptr datalog; + std::unique_ptr datalog; neorados::RADOS& rados() noexcept { return *rados_; } const std::string& pool_name() const noexcept { return pool_name_; } @@ -170,7 +170,7 @@ protected: } auto recover(const DoutPrefixProvider* dpp) { - return datalog->recover(dpp, datalog->shared_from_this()); + return datalog->recover(dpp); } void add_to_cur_cycle(const BucketGen& bg) { @@ -199,7 +199,7 @@ public: /// \brief Delete pool used for testing boost::asio::awaitable CoTearDown() override { - co_await datalog->shutdown(); + co_await datalog->async_shutdown(); co_await clean_pool(); co_return; } @@ -207,8 +207,8 @@ public: class DataLogTest : public DataLogTestBase { private: - asio::awaitable> create_datalog() override { - auto datalog = std::make_shared(rados().cct(), true, + asio::awaitable> create_datalog() override { + auto datalog = std::make_unique(rados().cct(), true, rados()); co_await datalog->start(dpp(), rgw_pool(pool_name()), false, true, false); co_return std::move(datalog); @@ -217,8 +217,8 @@ private: class DataLogWatchless : public DataLogTestBase { private: - asio::awaitable> create_datalog() override { - auto datalog = std::make_shared(rados().cct(), true, + asio::awaitable> create_datalog() override { + auto datalog = std::make_unique(rados().cct(), true, rados()); co_await datalog->start(dpp(), rgw_pool(pool_name()), false, false, false); co_return std::move(datalog); @@ -227,10 +227,10 @@ private: class DataLogBulky : public DataLogTestBase { private: - asio::awaitable> create_datalog() override { + asio::awaitable> create_datalog() override { // Decrease max push/list and force everything into one shard so we // can test iterated increment/decrement/list code. - auto datalog = std::make_shared(rados().cct(), true, + auto datalog = std::make_unique(rados().cct(), true, rados(), 1, 7); co_await datalog->start(dpp(), rgw_pool(pool_name()), false, true, false); co_return std::move(datalog); diff --git a/src/test/rgw/test_rgw_iam_policy.cc b/src/test/rgw/test_rgw_iam_policy.cc index 8e9be5c11e5..d3ebb7e26a3 100644 --- a/src/test/rgw/test_rgw_iam_policy.cc +++ b/src/test/rgw/test_rgw_iam_policy.cc @@ -21,18 +21,14 @@ #include +#include "rgw_sal_store.h" + #include "include/stringify.h" -#include "common/async/context_pool.h" -#include "common/code_environment.h" #include "common/ceph_context.h" -#include "global/global_init.h" #include "rgw_auth.h" -#include "rgw_auth_registry.h" #include "rgw_iam_managed_policy.h" #include "rgw_op.h" #include "rgw_process_env.h" -#include "rgw_sal_rados.h" -#include "driver/rados/rgw_zone.h" #include "rgw_sal_config.h" using std::string; @@ -1113,18 +1109,56 @@ TEST_F(IPPolicyTest, asNetworkInvalid) { EXPECT_FALSE(rgw::IAM::Condition::as_network("1.2.3.10000")); } +class DumbUser : public rgw::sal::StoreUser { + using StoreUser::StoreUser; + std::unique_ptr clone() { + return std::make_unique(*this); + } + int read_attrs(const DoutPrefixProvider*, optional_yield) { + return -ENOTSUP; + } + int merge_and_store_attrs(const DoutPrefixProvider*, rgw::sal::Attrs&, + optional_yield) { + return -ENOTSUP; + } + int read_usage(const DoutPrefixProvider*, uint64_t, uint64_t, uint32_t, + bool*, RGWUsageIter&, + std::map&) { + return -ENOTSUP; + } + virtual int trim_usage(const DoutPrefixProvider*, uint64_t, + uint64_t, optional_yield) { + return -ENOTSUP; + } + int load_user(const DoutPrefixProvider* dpp, optional_yield y) { + return -ENOTSUP; + } + int store_user(const DoutPrefixProvider*, optional_yield, bool, RGWUserInfo*) { + return -ENOTSUP; + } + int remove_user(const DoutPrefixProvider*, optional_yield) { + return -ENOTSUP; + } + int verify_mfa(const std::string&, bool*, const DoutPrefixProvider*, + optional_yield) { + return -ENOTSUP; + } + int list_groups(const DoutPrefixProvider*, optional_yield, + std::string_view, uint32_t, rgw::sal::GroupList&) { + return -ENOTSUP; + } +}; + TEST_F(IPPolicyTest, IPEnvironment) { RGWProcessEnv penv; // Unfortunately RGWCivetWeb is too tightly tied to civetweb to test RGWCivetWeb::init_env. RGWEnv rgw_env; - ceph::async::io_context_pool context_pool(cct->_conf->rgw_thread_pool_size); \ - rgw::sal::RadosStore store(context_pool); - std::unique_ptr user = store.get_user(rgw_user()); + std::unique_ptr user = std::make_unique(rgw_user()); rgw_env.set("REMOTE_ADDR", "192.168.1.1"); rgw_env.set("HTTP_HOST", "1.2.3.4"); req_state rgw_req_state(cct.get(), penv, &rgw_env, 0); rgw_req_state.set_user(user); - rgw_build_iam_environment(&store, &rgw_req_state); + rgw_build_iam_environment(&rgw_req_state); auto ip = rgw_req_state.env.find("aws:SourceIp"); ASSERT_NE(ip, rgw_req_state.env.end()); EXPECT_EQ(ip->second, "192.168.1.1"); @@ -1132,13 +1166,13 @@ TEST_F(IPPolicyTest, IPEnvironment) { ASSERT_EQ(cct.get()->_conf.set_val("rgw_remote_addr_param", "SOME_VAR"), 0); EXPECT_EQ(cct.get()->_conf->rgw_remote_addr_param, "SOME_VAR"); rgw_req_state.env.clear(); - rgw_build_iam_environment(&store, &rgw_req_state); + rgw_build_iam_environment(&rgw_req_state); ip = rgw_req_state.env.find("aws:SourceIp"); EXPECT_EQ(ip, rgw_req_state.env.end()); rgw_env.set("SOME_VAR", "192.168.1.2"); rgw_req_state.env.clear(); - rgw_build_iam_environment(&store, &rgw_req_state); + rgw_build_iam_environment(&rgw_req_state); ip = rgw_req_state.env.find("aws:SourceIp"); ASSERT_NE(ip, rgw_req_state.env.end()); EXPECT_EQ(ip->second, "192.168.1.2"); @@ -1146,14 +1180,14 @@ TEST_F(IPPolicyTest, IPEnvironment) { ASSERT_EQ(cct.get()->_conf.set_val("rgw_remote_addr_param", "HTTP_X_FORWARDED_FOR"), 0); rgw_env.set("HTTP_X_FORWARDED_FOR", "192.168.1.3"); rgw_req_state.env.clear(); - rgw_build_iam_environment(&store, &rgw_req_state); + rgw_build_iam_environment(&rgw_req_state); ip = rgw_req_state.env.find("aws:SourceIp"); ASSERT_NE(ip, rgw_req_state.env.end()); EXPECT_EQ(ip->second, "192.168.1.3"); rgw_env.set("HTTP_X_FORWARDED_FOR", "192.168.1.4, 4.3.2.1, 2001:db8:85a3:8d3:1319:8a2e:370:7348"); rgw_req_state.env.clear(); - rgw_build_iam_environment(&store, &rgw_req_state); + rgw_build_iam_environment(&rgw_req_state); ip = rgw_req_state.env.find("aws:SourceIp"); ASSERT_NE(ip, rgw_req_state.env.end()); EXPECT_EQ(ip->second, "192.168.1.4"); diff --git a/src/test/rgw/test_rgw_lua.cc b/src/test/rgw/test_rgw_lua.cc index 21f12c4efd1..81b7833358a 100644 --- a/src/test/rgw/test_rgw_lua.cc +++ b/src/test/rgw/test_rgw_lua.cc @@ -1,8 +1,5 @@ #include -#include "common/async/context_pool.h" -#include "common/ceph_context.h" #include "rgw_common.h" -#include "rgw_auth_registry.h" #include "rgw_process_env.h" #include "rgw_sal_rados.h" #include "rgw_lua_request.h" @@ -173,22 +170,6 @@ CctCleaner cleaner(g_cct); tracing::Tracer tracer; -inline std::unique_ptr make_store() { - auto context_pool = std::make_unique( - g_cct->_conf->rgw_thread_pool_size); - - struct StoreBundle : public sal::RadosStore { - std::unique_ptr context_pool; - StoreBundle(std::unique_ptr context_pool_) - : sal::RadosStore(*context_pool_.get()), - context_pool(std::move(context_pool_)) { - setRados(new RGWRados); - } - virtual ~StoreBundle() = default; - }; - return std::make_unique(std::move(context_pool)); -}; - class TestLuaManager : public rgw::sal::StoreLuaManager { public: std::string lua_script; @@ -232,7 +213,6 @@ void set_read_time(rgw::sal::LuaManager* manager, unsigned read_time) { } #define DEFINE_REQ_STATE RGWProcessEnv pe; \ - auto store = make_store(); \ pe.lua.manager = std::make_unique(); \ RGWEnv e; \ req_state s(g_cct, pe, &e, 0); @@ -246,7 +226,7 @@ TEST(TestRGWLua, EmptyScript) DEFINE_REQ_STATE; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -259,7 +239,7 @@ TEST(TestRGWLua, SyntaxError) DEFINE_REQ_STATE; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, -1); } @@ -271,7 +251,7 @@ TEST(TestRGWLua, Hello) DEFINE_REQ_STATE; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -283,7 +263,7 @@ TEST(TestRGWLua, RGWDebugLogNumber) DEFINE_REQ_STATE; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -295,7 +275,7 @@ TEST(TestRGWLua, RGWDebugNil) DEFINE_REQ_STATE; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, -1); } @@ -309,7 +289,7 @@ TEST(TestRGWLua, URI) DEFINE_REQ_STATE; s.decoded_uri = "http://hello.world/"; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -328,7 +308,7 @@ TEST(TestRGWLua, Response) s.err.err_code = "Bad Request"; s.err.message = "This is a bad request"; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -343,7 +323,7 @@ TEST(TestRGWLua, SetResponse) DEFINE_REQ_STATE; s.err.message = "this is a bad request"; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -357,7 +337,7 @@ TEST(TestRGWLua, RGWIdNotWriteable) DEFINE_REQ_STATE; s.host_id = "foo"; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_NE(rc, 0); } @@ -370,7 +350,7 @@ TEST(TestRGWLua, InvalidField) DEFINE_REQ_STATE; s.host_id = "foo"; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, -1); } @@ -382,7 +362,7 @@ TEST(TestRGWLua, InvalidSubField) DEFINE_REQ_STATE; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, -1); } @@ -415,7 +395,7 @@ TEST(TestRGWLua, Bucket) info.owner = rgw_user{"mytenant", "myuser"}; s.bucket.reset(new sal::RadosBucket(nullptr, info)); - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -430,7 +410,7 @@ TEST(TestRGWLua, WriteBucket) DEFINE_REQ_STATE; s.init_state.url_bucket = "myname"; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); ASSERT_EQ(s.init_state.url_bucket, "othername"); } @@ -448,7 +428,7 @@ TEST(TestRGWLua, WriteBucketFail) b.name = "myname"; s.bucket.reset(new sal::RadosBucket(nullptr, b)); - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_NE(rc, 0); } @@ -471,7 +451,7 @@ TEST(TestRGWLua, GenericAttributes) s.generic_attrs["goodbye"] = "cruel world"; s.generic_attrs["ka"] = "boom"; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -493,7 +473,7 @@ TEST(TestRGWLua, Environment) s.env.emplace("goodbye", "cruel world"); s.env.emplace("ka", "boom"); - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -514,7 +494,7 @@ TEST(TestRGWLua, Tags) s.tagset.add_tag("goodbye", "cruel world"); s.tagset.add_tag("ka", "boom"); - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -527,7 +507,7 @@ TEST(TestRGWLua, TagsNotWriteable) DEFINE_REQ_STATE; s.tagset.add_tag("hello", "world"); - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_NE(rc, 0); } @@ -553,7 +533,7 @@ TEST(TestRGWLua, Metadata) s.info.x_meta_map["foo"] = "bar"; s.info.x_meta_map["ka"] = "boom"; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -580,7 +560,7 @@ TEST(TestRGWLua, WriteMetadata) s.info.x_meta_map["foo"] = "bar"; s.info.x_meta_map["ka"] = "boom"; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -619,7 +599,7 @@ TEST(TestRGWLua, MetadataIterateWrite) s.info.x_meta_map["f"] = "6"; s.info.x_meta_map["g"] = "7"; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); ASSERT_EQ(s.info.x_meta_map.count("c"), 0); } @@ -650,7 +630,7 @@ TEST(TestRGWLua, MetadataIterator) end )"; - auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_NE(rc, 0); script = R"( @@ -672,7 +652,7 @@ TEST(TestRGWLua, MetadataIterator) end )"; - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_NE(rc, 0); script = R"( @@ -693,7 +673,7 @@ TEST(TestRGWLua, MetadataIterator) assert(counter == #Request.HTTP.Metadata) )"; - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -753,7 +733,7 @@ TEST(TestRGWLua, Acl) s.user_acl.get_acl().add_grant(grant5); s.user_acl.get_acl().add_grant(grant6_1); s.user_acl.get_acl().add_grant(grant6_2); - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -769,7 +749,7 @@ TEST(TestRGWLua, User) s.user.reset(new sal::RadosUser(nullptr, rgw_user("mytenant", "myid"))); - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -809,7 +789,7 @@ TEST(TestRGWLua, UseFunction) s.object_acl.get_owner().display_name = "user five"; s.object_acl.get_owner().id = rgw_user("tenant5", "user5"); - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -830,7 +810,7 @@ TEST(TestRGWLua, WithLib) b.name = "my-bucket-name-is-fish"; s.bucket.reset(new sal::RadosBucket(nullptr, b)); - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -843,7 +823,7 @@ TEST(TestRGWLua, NotAllowedInLib) DEFINE_REQ_STATE; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_NE(rc, 0); } @@ -886,21 +866,21 @@ TEST(TestRGWLua, OpsLog) s.auth.identity = std::unique_ptr( new FakeIdentity()); - auto rc = lua::request::execute(store.get(), nullptr, &olog, &s, nullptr, script); + auto rc = lua::request::execute(nullptr, &olog, &s, nullptr, script); EXPECT_EQ(rc, 0); EXPECT_FALSE(olog.logged); // don't log http_ret=200 s.err.http_ret = 400; - rc = lua::request::execute(store.get(), nullptr, &olog, &s, nullptr, script); + rc = lua::request::execute(nullptr, &olog, &s, nullptr, script); EXPECT_EQ(rc, 0); EXPECT_TRUE(olog.logged); } class TestBackground : public rgw::lua::Background { public: - TestBackground(sal::RadosStore* store, rgw::sal::LuaManager* manager) : - rgw::lua::Background(store, - g_cct, + TestBackground(rgw::sal::LuaManager* manager) : + rgw::lua::Background( + g_cct, manager, 1 /* run every second */) { } @@ -912,15 +892,14 @@ public: TEST(TestRGWLuaBackground, Start) { - auto store = make_store(); auto manager = std::make_unique(); { // ctr and dtor without running - TestBackground lua_background(store.get(), manager.get()); + TestBackground lua_background(manager.get()); } { // ctr and dtor with running - TestBackground lua_background(store.get(), manager.get()); + TestBackground lua_background(manager.get()); lua_background.start(); } } @@ -954,10 +933,9 @@ TEST(TestRGWLuaBackground, Script) RGW[key] = value )"; - auto store = make_store(); auto manager = std::make_unique(); set_script(manager.get(), script); - TestBackground lua_background(store.get(), manager.get()); + TestBackground lua_background(manager.get()); lua_background.start(); WAIT_FOR_BACKGROUND; EXPECT_EQ(get_table_value(lua_background, "hello"), "world"); @@ -973,7 +951,7 @@ TEST(TestRGWLuaBackground, RequestScript) DEFINE_REQ_STATE; set_script(pe.lua.manager.get(), background_script); - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); lua_background.start(); WAIT_FOR_BACKGROUND; @@ -988,12 +966,12 @@ TEST(TestRGWLuaBackground, RequestScript) // to make sure test is consistent we have to pause the background lua_background.pause(); - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_EQ(rc, 0); EXPECT_EQ(get_table_value(lua_background, "hello"), "from request"); // now we resume and let the background set the value perfcounter->set(l_rgw_lua_script_ok, 0); - lua_background.resume(store.get()); + lua_background.resume(nullptr); WAIT_FOR_BACKGROUND; EXPECT_EQ(get_table_value(lua_background, "hello"), "from background"); } @@ -1010,10 +988,9 @@ TEST(TestRGWLuaBackground, Pause) end )"; - auto store = make_store(); auto manager = std::make_unique(); set_script(manager.get(), script); - TestBackground lua_background(store.get(), manager.get()); + TestBackground lua_background(manager.get()); lua_background.start(); WAIT_FOR_BACKGROUND; const auto value_len = get_table_value(lua_background, "hello").size(); @@ -1038,11 +1015,10 @@ TEST(TestRGWLuaBackground, PauseWhileReading) end )"; - auto store = make_store(); auto manager = std::make_unique(); set_script(manager.get(), script); set_read_time(manager.get(), 2); - TestBackground lua_background(store.get(), manager.get()); + TestBackground lua_background(manager.get()); lua_background.start(); WAIT_FOR_BACKGROUND; const auto value_len = get_table_value(lua_background, "hello").size(); @@ -1062,16 +1038,15 @@ TEST(TestRGWLuaBackground, ReadWhilePaused) RGW[key] = value )"; - auto store = make_store(); auto manager = std::make_unique(); set_script(manager.get(), script); - TestBackground lua_background(store.get(), manager.get()); + TestBackground lua_background(manager.get()); lua_background.pause(); lua_background.start(); // make sure no execution occurs std::this_thread::sleep_for(wait_time*10); EXPECT_EQ(get_table_value(lua_background, "hello"), ""); - lua_background.resume(store.get()); + lua_background.resume(nullptr); WAIT_FOR_BACKGROUND; EXPECT_EQ(get_table_value(lua_background, "hello"), "world"); } @@ -1088,10 +1063,9 @@ TEST(TestRGWLuaBackground, PauseResume) end )"; - auto store = make_store(); auto manager = std::make_unique(); set_script(manager.get(), script); - TestBackground lua_background(store.get(), manager.get()); + TestBackground lua_background(manager.get()); lua_background.start(); WAIT_FOR_BACKGROUND; const auto value_len = get_table_value(lua_background, "hello").size(); @@ -1102,7 +1076,7 @@ TEST(TestRGWLuaBackground, PauseResume) // no change in len EXPECT_EQ(value_len, get_table_value(lua_background, "hello").size()); perfcounter->set(l_rgw_lua_script_ok, 0); - lua_background.resume(store.get()); + lua_background.resume(nullptr); WAIT_FOR_BACKGROUND; // should be a change in len EXPECT_GT(get_table_value(lua_background, "hello").size(), value_len); @@ -1120,10 +1094,9 @@ TEST(TestRGWLuaBackground, MultipleStarts) end )"; - auto store = make_store(); auto manager = std::make_unique(); set_script(manager.get(), script); - TestBackground lua_background(store.get(), manager.get()); + TestBackground lua_background(manager.get()); lua_background.start(); WAIT_FOR_BACKGROUND; const auto value_len = get_table_value(lua_background, "hello").size(); @@ -1141,7 +1114,7 @@ TEST(TestRGWLuaBackground, MultipleStarts) TEST(TestRGWLuaBackground, TableValues) { DEFINE_REQ_STATE; - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); const std::string request_script = R"( RGW["key1"] = "string value" @@ -1152,7 +1125,7 @@ TEST(TestRGWLuaBackground, TableValues) pe.lua.background = &lua_background; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_EQ(rc, 0); EXPECT_EQ(get_table_value(lua_background, "key1"), "string value"); EXPECT_EQ(get_table_value(lua_background, "key2"), 42); @@ -1163,7 +1136,7 @@ TEST(TestRGWLuaBackground, TableValues) TEST(TestRGWLuaBackground, TablePersist) { DEFINE_REQ_STATE; - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); std::string request_script = R"( RGW["key1"] = "string value" @@ -1172,7 +1145,7 @@ TEST(TestRGWLuaBackground, TablePersist) pe.lua.background = &lua_background; - auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_EQ(rc, 0); EXPECT_EQ(get_table_value(lua_background, "key1"), "string value"); EXPECT_EQ(get_table_value(lua_background, "key2"), 42); @@ -1182,7 +1155,7 @@ TEST(TestRGWLuaBackground, TablePersist) RGW["key4"] = RGW["key2"] )"; - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_EQ(rc, 0); EXPECT_EQ(get_table_value(lua_background, "key1"), "string value"); EXPECT_EQ(get_table_value(lua_background, "key2"), 42); @@ -1193,7 +1166,7 @@ TEST(TestRGWLuaBackground, TablePersist) TEST(TestRGWLuaBackground, TableValuesFromRequest) { DEFINE_REQ_STATE; - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); lua_background.start(); const std::string request_script = R"( @@ -1210,7 +1183,7 @@ TEST(TestRGWLuaBackground, TableValuesFromRequest) s.err.ret = -99; s.err.message = "hi"; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_EQ(rc, 0); EXPECT_EQ(get_table_value(lua_background, "key1"), -99); EXPECT_EQ(get_table_value(lua_background, "key2"), "hi"); @@ -1221,7 +1194,7 @@ TEST(TestRGWLuaBackground, TableValuesFromRequest) TEST(TestRGWLuaBackground, TableInvalidValue) { DEFINE_REQ_STATE; - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); lua_background.start(); const std::string request_script = R"( @@ -1236,7 +1209,7 @@ TEST(TestRGWLuaBackground, TableInvalidValue) s.tagset.add_tag("key1", "val1"); s.tagset.add_tag("key2", "val2"); - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_NE(rc, 0); EXPECT_EQ(get_table_value(lua_background, "key1"), "val1"); EXPECT_EQ(get_table_value(lua_background, "key2"), 42); @@ -1247,7 +1220,7 @@ TEST(TestRGWLuaBackground, TableInvalidValue) TEST(TestRGWLuaBackground, TableErase) { DEFINE_REQ_STATE; - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); std::string request_script = R"( RGW["size"] = 0 @@ -1259,7 +1232,7 @@ TEST(TestRGWLuaBackground, TableErase) pe.lua.background = &lua_background; - auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_EQ(rc, 0); EXPECT_EQ(get_table_value(lua_background, "key1"), "string value"); EXPECT_EQ(get_table_value(lua_background, "key2"), 42); @@ -1274,7 +1247,7 @@ TEST(TestRGWLuaBackground, TableErase) RGW["size"] = #RGW )"; - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_EQ(rc, 0); EXPECT_EQ(get_table_value(lua_background, "key1"), ""); EXPECT_EQ(get_table_value(lua_background, "key2"), 42); @@ -1285,7 +1258,7 @@ TEST(TestRGWLuaBackground, TableErase) TEST(TestRGWLuaBackground, TableIterate) { DEFINE_REQ_STATE; - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); const std::string request_script = R"( RGW["key1"] = "string value" @@ -1300,7 +1273,7 @@ TEST(TestRGWLuaBackground, TableIterate) pe.lua.background = &lua_background; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_EQ(rc, 0); EXPECT_EQ(get_table_value(lua_background, "key1"), "string value"); EXPECT_EQ(get_table_value(lua_background, "key2"), 42); @@ -1312,7 +1285,7 @@ TEST(TestRGWLuaBackground, TableIterate) TEST(TestRGWLuaBackground, TableIterateWrite) { DEFINE_REQ_STATE; - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); const std::string request_script = R"( RGW["a"] = 1 @@ -1334,7 +1307,7 @@ TEST(TestRGWLuaBackground, TableIterateWrite) pe.lua.background = &lua_background; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_EQ(rc, 0); EXPECT_EQ(lua_background.get_table_value("c"), TestBackground::empty_table_value); } @@ -1342,7 +1315,7 @@ TEST(TestRGWLuaBackground, TableIterateWrite) TEST(TestRGWLuaBackground, TableIncrement) { DEFINE_REQ_STATE; - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); const std::string request_script = R"( RGW["key1"] = 42 @@ -1355,14 +1328,14 @@ TEST(TestRGWLuaBackground, TableIncrement) pe.lua.background = &lua_background; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_EQ(rc, 0); } TEST(TestRGWLuaBackground, TableIncrementBy) { DEFINE_REQ_STATE; - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); const std::string request_script = R"( RGW["key1"] = 42 @@ -1377,14 +1350,14 @@ TEST(TestRGWLuaBackground, TableIncrementBy) pe.lua.background = &lua_background; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_EQ(rc, 0); } TEST(TestRGWLuaBackground, TableDecrement) { DEFINE_REQ_STATE; - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); const std::string request_script = R"( RGW["key1"] = 42 @@ -1397,14 +1370,14 @@ TEST(TestRGWLuaBackground, TableDecrement) pe.lua.background = &lua_background; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_EQ(rc, 0); } TEST(TestRGWLuaBackground, TableDecrementBy) { DEFINE_REQ_STATE; - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); const std::string request_script = R"( RGW["key1"] = 42 @@ -1419,14 +1392,14 @@ TEST(TestRGWLuaBackground, TableDecrementBy) pe.lua.background = &lua_background; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_EQ(rc, 0); } TEST(TestRGWLuaBackground, TableIncrementValueError) { DEFINE_REQ_STATE; - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); std::string request_script = R"( -- cannot increment string values @@ -1436,7 +1409,7 @@ TEST(TestRGWLuaBackground, TableIncrementValueError) pe.lua.background = &lua_background; - auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_NE(rc, 0); request_script = R"( @@ -1445,7 +1418,7 @@ TEST(TestRGWLuaBackground, TableIncrementValueError) RGW.increment("key1") )"; - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_NE(rc, 0); request_script = R"( @@ -1454,14 +1427,14 @@ TEST(TestRGWLuaBackground, TableIncrementValueError) RGW.increment("key1", "kaboom") )"; - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_NE(rc, 0); } TEST(TestRGWLuaBackground, TableIncrementError) { DEFINE_REQ_STATE; - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); std::string request_script = R"( -- missing argument @@ -1471,7 +1444,7 @@ TEST(TestRGWLuaBackground, TableIncrementError) pe.lua.background = &lua_background; - auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_NE(rc, 0); request_script = R"( @@ -1479,7 +1452,7 @@ TEST(TestRGWLuaBackground, TableIncrementError) RGW.increment = 11 )"; - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, request_script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, request_script); ASSERT_NE(rc, 0); } @@ -1493,7 +1466,7 @@ TEST(TestRGWLua, TracingSetAttribute) DEFINE_REQ_STATE; INIT_TRACE; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -1505,7 +1478,7 @@ TEST(TestRGWLua, TracingSetBadAttribute) DEFINE_REQ_STATE; INIT_TRACE; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); #ifdef HAVE_JAEGER ASSERT_NE(rc, 0); #else @@ -1527,7 +1500,7 @@ TEST(TestRGWLua, TracingAddEvent) DEFINE_REQ_STATE; INIT_TRACE; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -1550,7 +1523,7 @@ TEST(TestRGWLua, Data) )"; DEFINE_REQ_STATE; - TestBackground lua_background(store.get(), pe.lua.manager.get()); + TestBackground lua_background(pe.lua.manager.get()); s.host_id = "foo"; pe.lua.background = &lua_background; lua::RGWObjFilter filter(&s, script); @@ -1587,22 +1560,22 @@ TEST(TestRGWLua, MemoryLimit) // memory should be sufficient s.cct->_conf->rgw_lua_max_memory_per_state = 1024*32; - auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); // no memory limit s.cct->_conf->rgw_lua_max_memory_per_state = 0; - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); // not enough memory to start lua s.cct->_conf->rgw_lua_max_memory_per_state = 2048; - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_NE(rc, 0); // not enough memory for initial setup s.cct->_conf->rgw_lua_max_memory_per_state = 1024*16; - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_NE(rc, 0); // not enough memory for the script @@ -1613,7 +1586,7 @@ TEST(TestRGWLua, MemoryLimit) end )"; s.cct->_conf->rgw_lua_max_memory_per_state = 1024*32; - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_NE(rc, 0); } @@ -1625,12 +1598,12 @@ TEST(TestRGWLua, LuaRuntimeLimit) // runtime should be sufficient s.cct->_conf->rgw_lua_max_runtime_per_state = 1000; // 1 second runtime limit - int rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + int rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); // no runtime limit s.cct->_conf->rgw_lua_max_runtime_per_state = 0; - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); // script should exceed the runtime limit @@ -1642,11 +1615,11 @@ TEST(TestRGWLua, LuaRuntimeLimit) )"; s.cct->_conf->rgw_lua_max_runtime_per_state = 10; // 10 milliseconds runtime limit - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_NE(rc, 0); s.cct->_conf->rgw_lua_max_runtime_per_state = 0; // no runtime limit - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); // script should exceed the runtime limit @@ -1657,7 +1630,7 @@ TEST(TestRGWLua, LuaRuntimeLimit) )"; s.cct->_conf->rgw_lua_max_runtime_per_state = 5000; // 5 seconds runtime limit - rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_NE(rc, 0); } @@ -1684,7 +1657,7 @@ TEST(TestRGWLua, DifferentContextUser) info.owner = rgw_user{"tenant2", "user2"}; s.bucket.reset(new sal::RadosBucket(nullptr, info)); - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } @@ -1710,7 +1683,7 @@ TEST(TestRGWLua, NestedLoop) s.info.x_meta_map["33"] = "cc"; s.info.x_meta_map["44"] = "dd"; - const auto rc = lua::request::execute(nullptr, nullptr, nullptr, &s, nullptr, script); + const auto rc = lua::request::execute(nullptr, nullptr, &s, nullptr, script); ASSERT_EQ(rc, 0); } -- 2.39.5