]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/lua: pass luarocks_path directly, remove from sal 48710/head
authorCasey Bodley <cbodley@redhat.com>
Mon, 14 Nov 2022 21:22:00 +0000 (16:22 -0500)
committerCasey Bodley <cbodley@redhat.com>
Tue, 13 Dec 2022 18:52:58 +0000 (13:52 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
12 files changed:
src/rgw/driver/rados/rgw_sal_rados.h
src/rgw/rgw_appmain.cc
src/rgw/rgw_lua.cc
src/rgw/rgw_lua.h
src/rgw/rgw_lua_request.cc
src/rgw/rgw_process_env.h
src/rgw/rgw_sal.h
src/rgw/rgw_sal_daos.h
src/rgw/rgw_sal_dbstore.h
src/rgw/rgw_sal_filter.cc
src/rgw/rgw_sal_filter.h
src/rgw/rgw_sal_motr.h

index 499e0994807612fd0b2b3e8c57128dc78ffafb44..cfd611c6e2794e32cbfe07af01c61d0ad8c6b884 100644 (file)
@@ -124,7 +124,6 @@ class RadosStore : public StoreDriver {
   private:
     RGWRados* rados;
     RGWUserCtl* user_ctl;
-    std::string luarocks_path;
     std::unique_ptr<RadosZone> 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 */
index 396cc5b9b416ffe6e4ff41e3110a251584e7b8a4..69672fa807d52b35e835b4201dc3e19143360507 100644 (file)
@@ -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<std::string>("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<std::string>("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();
   }
index 28c57ddbc4306f3a4c6941c777aebf8273734cec..33af6037011bb9e7eca184bf94ea928b12ef4cd8 100644 (file)
@@ -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<std::uintmax_t>(-1) &&
       ec != std::errc::no_such_file_or_directory) {
index b76795750b2e1d8369b2d0a40b97dae1e3f69725..a6ebcc2d0e1153d586af5db01cdbc8274a671f55 100644 (file)
@@ -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
 }
 
index 53b055bf3883cc4ac74649c5e3fd18fe8fff7c70..6d324d4fcaab67a076ca97e497d756a2f7d87a13 100644 (file)
@@ -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);  
   
index f1577608e3ccc92d89ad6805c864d62afea952a5..7e62b6afcd491b48a6108bb5e3ea3fe9cd2b15ce 100644 (file)
@@ -21,6 +21,7 @@ namespace rgw::sal {
 }
 
 struct RGWLuaProcessEnv {
+  std::string luarocks_path;
   rgw::lua::Background* background = nullptr;
   std::unique_ptr<rgw::sal::LuaManager> manager;
 };
index 1a24045adf184de42e00fa40707163fe60d1d0e1..931e9ff505c57cfae87f0acdbbf51d5debe1d405 100644 (file)
@@ -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;
 };
index f172a8abe3bf9c3775f0fd932e0fecc978123070..b9fba5cce8731cee0adf0822c4b2e3975eed6088 100644 (file)
@@ -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;
 };
index a7f496191c73fb216393f61223e2c3096193f6c2..c9c07d22ac5455b314b6aa61141f9f8d547635cb 100644 (file)
@@ -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 */
index ba5ed02322708fa9aead846947c1201606bbb5fe..9888f4bb2f383ed9827097f9ae62acfc46f7efaf 100644 (file)
@@ -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)
index 88bd81ee10d9e796c730352115ae21bdf50f047d..19929056007bfbcada4d20a8c044a2a31011a62d 100644 (file)
@@ -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);
   }
 };
index ad9328b95197502efdaa2b5820d982570caa95d7..5b877b7b890e32a199e32d5bc93989a0937482ca 100644 (file)
@@ -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);