From: Casey Bodley Date: Mon, 14 Nov 2022 21:22:00 +0000 (-0500) Subject: rgw/lua: pass luarocks_path directly, remove from sal X-Git-Tag: v18.1.0~650^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0ca2f95469f327152b65e83c032b8ba76b04728c;p=ceph.git rgw/lua: pass luarocks_path directly, remove from sal Signed-off-by: Casey Bodley --- diff --git a/src/rgw/driver/rados/rgw_sal_rados.h b/src/rgw/driver/rados/rgw_sal_rados.h index 499e09948076..cfd611c6e279 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.h +++ b/src/rgw/driver/rados/rgw_sal_rados.h @@ -124,7 +124,6 @@ class RadosStore : public StoreDriver { private: RGWRados* rados; RGWUserCtl* user_ctl; - std::string luarocks_path; std::unique_ptr zone; public: @@ -241,13 +240,6 @@ class RadosStore : public StoreDriver { virtual CephContext* ctx(void) override { return rados->ctx(); } - virtual const std::string& get_luarocks_path() const override { - return luarocks_path; - } - - virtual void set_luarocks_path(const std::string& path) override { - luarocks_path = path; - } virtual void register_admin_apis(RGWRESTMgr* mgr) override; /* Unique to RadosStore */ diff --git a/src/rgw/rgw_appmain.cc b/src/rgw/rgw_appmain.cc index 396cc5b9b416..69672fa807d5 100644 --- a/src/rgw/rgw_appmain.cc +++ b/src/rgw/rgw_appmain.cc @@ -509,18 +509,17 @@ void rgw::AppMain::init_lua() { rgw::sal::Driver* driver = env.driver; int r{0}; - const auto &luarocks_path = - g_conf().get_val("rgw_luarocks_location"); - if (luarocks_path.empty()) { - driver->set_luarocks_path(""); - } else { - driver->set_luarocks_path(luarocks_path + "/" + g_conf()->name.to_str()); + std::string path = g_conf().get_val("rgw_luarocks_location"); + if (!path.empty()) { + path += "/" + g_conf()->name.to_str(); } + env.lua.luarocks_path = path; + #ifdef WITH_RADOSGW_LUA_PACKAGES rgw::lua::packages_t failed_packages; std::string output; - r = rgw::lua::install_packages(dpp, driver, null_yield, failed_packages, - output); + r = rgw::lua::install_packages(dpp, driver, null_yield, path, + failed_packages, output); if (r < 0) { dout(1) << "WARNING: failed to install lua packages from allowlist" << dendl; @@ -538,7 +537,7 @@ void rgw::AppMain::init_lua() if (driver->get_name() == "rados") { /* Supported for only RadosStore */ lua_background = std::make_unique< - rgw::lua::Background>(driver, dpp->get_cct(), driver->get_luarocks_path()); + rgw::lua::Background>(driver, dpp->get_cct(), path); lua_background->start(); env.lua.background = lua_background.get(); } diff --git a/src/rgw/rgw_lua.cc b/src/rgw/rgw_lua.cc index 28c57ddbc430..33af6037011b 100644 --- a/src/rgw/rgw_lua.cc +++ b/src/rgw/rgw_lua.cc @@ -154,10 +154,11 @@ int list_packages(const DoutPrefixProvider *dpp, rgw::sal::Driver* driver, optio return lua_mgr->list_packages(dpp, y, packages); } -int install_packages(const DoutPrefixProvider *dpp, rgw::sal::Driver* driver, optional_yield y, packages_t& failed_packages, std::string& output) { +int install_packages(const DoutPrefixProvider *dpp, rgw::sal::Driver* driver, + optional_yield y, const std::string& luarocks_path, + packages_t& failed_packages, std::string& output) { // luarocks directory cleanup std::error_code ec; - const auto& luarocks_path = driver->get_luarocks_path(); if (std::filesystem::remove_all(luarocks_path, ec) == static_cast(-1) && ec != std::errc::no_such_file_or_directory) { diff --git a/src/rgw/rgw_lua.h b/src/rgw/rgw_lua.h index b76795750b2e..a6ebcc2d0e11 100644 --- a/src/rgw/rgw_lua.h +++ b/src/rgw/rgw_lua.h @@ -59,7 +59,9 @@ int list_packages(const DoutPrefixProvider *dpp, rgw::sal::Driver* driver, optio // install all packages from the allowlist // return the list of packages that failed to install and the output of the install command -int install_packages(const DoutPrefixProvider *dpp, rgw::sal::Driver* driver, optional_yield y, packages_t& failed_packages, std::string& output); +int install_packages(const DoutPrefixProvider *dpp, rgw::sal::Driver* driver, + optional_yield y, const std::string& luarocks_path, + packages_t& failed_packages, std::string& output); #endif } diff --git a/src/rgw/rgw_lua_request.cc b/src/rgw/rgw_lua_request.cc index 53b055bf3883..6d324d4fcaab 100644 --- a/src/rgw/rgw_lua_request.cc +++ b/src/rgw/rgw_lua_request.cc @@ -859,9 +859,7 @@ int execute( lua_state_guard lguard(L); open_standard_libs(L); - set_package_path(L, driver ? - driver->get_luarocks_path() : - ""); + set_package_path(L, s->penv.lua.luarocks_path); create_debug_action(L, s->cct); diff --git a/src/rgw/rgw_process_env.h b/src/rgw/rgw_process_env.h index f1577608e3cc..7e62b6afcd49 100644 --- a/src/rgw/rgw_process_env.h +++ b/src/rgw/rgw_process_env.h @@ -21,6 +21,7 @@ namespace rgw::sal { } struct RGWLuaProcessEnv { + std::string luarocks_path; rgw::lua::Background* background = nullptr; std::unique_ptr manager; }; diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 1a24045adf18..931e9ff505c5 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -448,10 +448,6 @@ class Driver { /** Get the Ceph context associated with this driver. May be removed. */ virtual CephContext* ctx(void) = 0; - /** Get the location of where lua packages are installed */ - virtual const std::string& get_luarocks_path() const = 0; - /** Set the location of where lua packages are installed */ - virtual void set_luarocks_path(const std::string& path) = 0; /** Register admin APIs unique to this driver */ virtual void register_admin_apis(RGWRESTMgr* mgr) = 0; }; diff --git a/src/rgw/rgw_sal_daos.h b/src/rgw/rgw_sal_daos.h index f172a8abe3bf..b9fba5cce873 100644 --- a/src/rgw/rgw_sal_daos.h +++ b/src/rgw/rgw_sal_daos.h @@ -881,7 +881,6 @@ class DaosMultipartUpload : public StoreMultipartUpload { class DaosStore : public StoreDriver { private: - std::string luarocks_path; DaosZone zone; RGWSyncModuleInstanceRef sync_module; @@ -1044,14 +1043,6 @@ class DaosStore : public StoreDriver { virtual CephContext* ctx(void) override { return cctx; } - virtual const std::string& get_luarocks_path() const override { - return luarocks_path; - } - - virtual void set_luarocks_path(const std::string& path) override { - luarocks_path = path; - } - virtual int initialize(CephContext* cct, const DoutPrefixProvider* dpp) override; }; diff --git a/src/rgw/rgw_sal_dbstore.h b/src/rgw/rgw_sal_dbstore.h index a7f496191c73..c9c07d22ac54 100644 --- a/src/rgw/rgw_sal_dbstore.h +++ b/src/rgw/rgw_sal_dbstore.h @@ -762,7 +762,6 @@ public: * multiple db handles (for eg., one for each tenant), * use dbsm->getDB(tenant) */ DB *db; - std::string luarocks_path; DBZone zone; RGWSyncModuleInstanceRef sync_module; RGWLC* lc; @@ -903,13 +902,6 @@ public: return db->ctx(); } - virtual const std::string& get_luarocks_path() const override { - return luarocks_path; - } - - virtual void set_luarocks_path(const std::string& path) override { - luarocks_path = path; - } virtual void register_admin_apis(RGWRESTMgr* mgr) override { }; /* Unique to DBStore */ diff --git a/src/rgw/rgw_sal_filter.cc b/src/rgw/rgw_sal_filter.cc index ba5ed0232270..9888f4bb2f38 100644 --- a/src/rgw/rgw_sal_filter.cc +++ b/src/rgw/rgw_sal_filter.cc @@ -542,16 +542,6 @@ CephContext* FilterDriver::ctx(void) return next->ctx(); } -const std::string& FilterDriver::get_luarocks_path() const -{ - return next->get_luarocks_path(); -} - -void FilterDriver::set_luarocks_path(const std::string& path) -{ - next->set_luarocks_path(path); -} - int FilterUser::list_buckets(const DoutPrefixProvider* dpp, const std::string& marker, const std::string& end_marker, uint64_t max, bool need_stats, BucketList &buckets, optional_yield y) diff --git a/src/rgw/rgw_sal_filter.h b/src/rgw/rgw_sal_filter.h index 88bd81ee10d9..19929056007b 100644 --- a/src/rgw/rgw_sal_filter.h +++ b/src/rgw/rgw_sal_filter.h @@ -305,9 +305,7 @@ public: virtual CephContext* ctx(void) override; - virtual const std::string& get_luarocks_path() const override; - virtual void set_luarocks_path(const std::string& path) override; - virtual void register_admin_apis(RGWRESTMgr* mgr)override { + virtual void register_admin_apis(RGWRESTMgr* mgr) override { return next->register_admin_apis(mgr); } }; diff --git a/src/rgw/rgw_sal_motr.h b/src/rgw/rgw_sal_motr.h index ad9328b95197..5b877b7b890e 100644 --- a/src/rgw/rgw_sal_motr.h +++ b/src/rgw/rgw_sal_motr.h @@ -899,7 +899,6 @@ public: class MotrStore : public StoreDriver { private: - std::string luarocks_path; MotrZone zone; RGWSyncModuleInstanceRef sync_module; @@ -1033,13 +1032,6 @@ class MotrStore : public StoreDriver { return cctx; } - virtual const std::string& get_luarocks_path() const override { - return luarocks_path; - } - - virtual void set_luarocks_path(const std::string& path) override { - luarocks_path = path; - } virtual void register_admin_apis(RGWRESTMgr* mgr) override { }; int open_idx(struct m0_uint128 *id, bool create, struct m0_idx *out);