]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
RGW/standalone: refactoring issues for ConfigStore and rgw_zone 62398/head
authorAli Masarwa <amasarwa@redhat.com>
Tue, 29 Apr 2025 08:18:06 +0000 (11:18 +0300)
committerAli Masarwa <amasarwa@redhat.com>
Tue, 29 Apr 2025 12:31:09 +0000 (15:31 +0300)
Signed-off-by: Ali Masarwa <amasarwa@redhat.com>
src/rgw/driver/rados/rgw_rados.cc
src/rgw/driver/rados/rgw_rados.h
src/rgw/driver/rados/rgw_rest_realm.cc
src/rgw/radosgw-admin/radosgw-admin.cc
src/rgw/rgw_rest_ratelimit.cc
src/rgw/rgw_sal.cc
src/rgw/services/svc_cls.h
src/rgw/services/svc_notify.h
src/rgw/services/svc_sys_obj_cache.h
src/test/rgw/test_d4n_filter.cc

index 33300a7b062639410c88d2024e683c43415c3668..93db5dd67a697a1d5bfe042a6b3e44821dd1b02c 100644 (file)
@@ -483,7 +483,7 @@ public:
 class RGWMetaSyncProcessorThread : public RGWSyncProcessorThread
 {
   RGWMetaSyncStatusManager sync;
-  rgw::sal::ConfigStore* cfgstore;
+  rgw::sal::ConfigStore *cfgstore{nullptr};
 
   uint64_t interval_msec() override {
     return 0; /* no interval associated, it'll run once until stopped */
@@ -492,8 +492,9 @@ class RGWMetaSyncProcessorThread : public RGWSyncProcessorThread
     sync.stop();
   }
 public:
-  RGWMetaSyncProcessorThread(rgw::sal::RadosStore* _driver, RGWAsyncRadosProcessor *async_rados)
-    : RGWSyncProcessorThread(_driver->getRados(), "meta-sync"), sync(_driver, async_rados) {}
+  RGWMetaSyncProcessorThread(rgw::sal::RadosStore* _driver, RGWAsyncRadosProcessor *async_rados,
+                             rgw::sal::ConfigStore *_cfgstore)
+    : RGWSyncProcessorThread(_driver->getRados(), "meta-sync"), sync(_driver, async_rados), cfgstore(_cfgstore) {}
 
   void wakeup_sync_shards(set<int>& shard_ids) {
     for (set<int>::iterator iter = shard_ids.begin(); iter != shard_ids.end(); ++iter) {
@@ -537,11 +538,11 @@ class RGWDataSyncProcessorThread : public RGWSyncProcessorThread
   }
 public:
   RGWDataSyncProcessorThread(rgw::sal::RadosStore* _driver, RGWAsyncRadosProcessor *async_rados,
-                             const RGWZone* source_zone)
+                             const RGWZone* source_zone, rgw::sal::ConfigStore *_cfgstore)
     : RGWSyncProcessorThread(_driver->getRados(), "data-sync"),
       counters(sync_counters::build(store->ctx(), std::string("data-sync-from-") + source_zone->name)),
       sync(_driver, async_rados, source_zone->id, counters.get()),
-      initialized(false) {}
+      initialized(false), cfgstore(_cfgstore) {}
 
   void wakeup_sync_shards(bc::flat_map<int, bc::flat_set<rgw_data_notify_entry> >& entries) {
     for (bc::flat_map<int, bc::flat_set<rgw_data_notify_entry> >::iterator iter = entries.begin(); iter != entries.end(); ++iter) {
@@ -1222,7 +1223,7 @@ int RGWRados::update_service_map(const DoutPrefixProvider *dpp, std::map<std::st
  * Initialize the RADOS instance and prepare to do other ops
  * Returns 0 on success, -ERR# on failure.
  */
-int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y)
+int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y, rgw::sal::ConfigStore* cfgstore)
 {
   int ret;
 
@@ -1306,7 +1307,7 @@ int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y)
     }
     auto async_processor = svc.async_processor;
     std::lock_guard l{meta_sync_thread_lock};
-    meta_sync_processor_thread = new RGWMetaSyncProcessorThread(this->driver, async_processor);
+    meta_sync_processor_thread = new RGWMetaSyncProcessorThread(this->driver, async_processor, cfgstore);
     ret = meta_sync_processor_thread->init(dpp);
     if (ret < 0) {
       ldpp_dout(dpp, 0) << "ERROR: failed to initialize meta sync thread" << dendl;
@@ -1329,7 +1330,7 @@ int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y)
     std::lock_guard dl{data_sync_thread_lock};
     for (auto source_zone : svc.zone->get_data_sync_source_zones()) {
       ldpp_dout(dpp, 5) << "starting data sync thread for zone " << source_zone->name << dendl;
-      auto *thread = new RGWDataSyncProcessorThread(this->driver, svc.async_processor, source_zone);
+      auto *thread = new RGWDataSyncProcessorThread(this->driver, svc.async_processor, source_zone, cfgstore);
       ret = thread->init(dpp);
       if (ret < 0) {
         ldpp_dout(dpp, 0) << "ERROR: failed to initialize data sync thread" << dendl;
index af92275ba3e0ec7245a2b3755ddf5652cec93135..0f4c28c9c144c2fa7b40f777543892eae10f8217 100644 (file)
@@ -599,7 +599,7 @@ public:
   /** Initialize the RADOS instance and prepare to do other ops */
   int init_svc(bool raw, const DoutPrefixProvider *dpp, bool background_tasks, const rgw::SiteConfig& site, rgw::sal::ConfigStore* cfgstore);
   virtual int init_rados();
-  int init_complete(const DoutPrefixProvider *dpp, optional_yield y);
+  int init_complete(const DoutPrefixProvider *dpp, optional_yield y, rgw::sal::ConfigStore* cfgstore);
   void finalize();
 
   int register_to_service_map(const DoutPrefixProvider *dpp, const std::string& daemon_type, const std::map<std::string, std::string>& meta);
index 4a482ff86a264970c240e3ddb0858bf636f2dd49..34234a04221c66bccd4867f8dfa047911924685c 100644 (file)
@@ -100,9 +100,6 @@ void RGWOp_Period_Post::execute(optional_yield y)
 {
   auto cct = driver->ctx();
 
-  // initialize the period without reading from rados
-  s->penv.cfgstore->read_period(this, y, driver->get_zone()->get_current_period_id(), std::nullopt, period);
-
   // decode the period from input
   const auto max_size = cct->_conf->rgw_max_put_param_size;
   bool empty;
@@ -144,10 +141,6 @@ void RGWOp_Period_Post::execute(optional_yield y)
 
   // if period id is empty, handle as 'period commit'
   if (period.get_id().empty()) {
-    if (op_ret < 0) {
-      cerr << "Error initializing realm: " << cpp_strerror(-op_ret) << std::endl;
-      return;
-    }
     op_ret = rgw::commit_period(this, y, s->penv.cfgstore, driver, realm, *realm_writer, current_period, period, error_stream, false);
     if (op_ret == -EEXIST) {
       op_ret = 0; // succeed on retries so the op is idempotent
@@ -309,7 +302,6 @@ void RGWOp_Realm_Get::execute(optional_yield y)
 
   // read realm
   realm.reset(new RGWRealm(id, name));
-  auto config_store_type = g_conf().get_val<std::string>("rgw_config_store");
   op_ret = rgw::read_realm(this, y, s->penv.cfgstore, realm->get_id(), realm->get_name(), *realm);
   if (op_ret < 0)
     ldpp_dout(this, -1) << "failed to read realm id=" << id
index 488ed958eafd1496b0041dca01fa7be5098f835b..12fd0c226e9cee04177cd1430d77b08e89c32a35 100644 (file)
@@ -4601,7 +4601,7 @@ int main(int argc, const char **argv)
                                         false,
                                        false, // No background tasks!
                                         null_yield,
-          cfgstore.get(),
+                                       cfgstore.get(),
                                        need_cache && g_conf()->rgw_cache_enabled,
                                        need_gc);
     }
index 4db3b3d4cfb4185054d1d44bee89a2875a339ebf..6637684ad67ebbad2754117da25ae0847fd499af 100644 (file)
@@ -105,7 +105,6 @@ void RGWOp_Ratelimit_Info::execute(optional_yield y)
   if (global) {
     std::string realm_id = driver->get_zone()->get_realm_id();
     RGWPeriodConfig period_config;
-    auto config_store_type = g_conf().get_val<std::string>("rgw_config_store");
     auto cfgstore = s->penv.cfgstore;
     op_ret = cfgstore->read_period_config(this, y, realm_id, period_config);
     if (op_ret && op_ret != -ENOENT) {
@@ -309,7 +308,6 @@ void RGWOp_Ratelimit_Set::execute(optional_yield y)
     return;
   }
 
-  auto config_store_type = g_conf().get_val<std::string>("rgw_config_store");
   auto cfgstore = s->penv.cfgstore;
   if (global) {
     std::string realm_id = driver->get_zone()->get_realm_id();
index 39e4402a2a3c001a38ee2ce31d6029e65f84834a..7195964ae8d88090ed80175428eff98b52accdce 100644 (file)
@@ -106,7 +106,7 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
       delete driver;
       return nullptr;
     }
-    if (rados->init_complete(dpp, y) < 0) {
+    if (rados->init_complete(dpp, y, cfgstore) < 0) {
       delete driver;
       return nullptr;
     }
@@ -133,7 +133,7 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
       delete driver;
       return nullptr;
     }
-    if (rados->init_complete(dpp, y) < 0) {
+    if (rados->init_complete(dpp, y, cfgstore) < 0) {
       delete driver;
       return nullptr;
     }
index 1decd8f3266aae84948480f594c732dd708e997d..08aaec2db2ebb82322b774c4df81c22a9239aa30 100644 (file)
@@ -28,7 +28,6 @@ class RGWSI_Cls : public RGWServiceInstance
 {
   RGWSI_Zone *zone_svc{nullptr};
   librados::Rados* rados{nullptr};
-  rgw::sal::ConfigStore* cfgstore{nullptr};
 
   class ClsSubService : public RGWServiceInstance {
     friend class RGWSI_Cls;
index fad4a6faae9f69a6c8b9ea71e3f6c44e408287f7..a13219c684b09186e37ff4b6d7cf7f9c11099768 100644 (file)
@@ -30,7 +30,6 @@ private:
   RGWSI_Zone *zone_svc{nullptr};
   librados::Rados *rados{nullptr};
   RGWSI_Finisher *finisher_svc{nullptr};
-  rgw::sal::ConfigStore *cfgstore{nullptr};
 
   ceph::shared_mutex watchers_lock = ceph::make_shared_mutex("watchers_lock");
   rgw_pool control_pool;
index a0db3aa94b2c91dc417bb3473e9fbb2b8ead43ee..9d0b14c51301c8019b8e85fa885810559bed1bb0 100644 (file)
@@ -26,7 +26,6 @@ class RGWSI_SysObj_Cache : public RGWSI_SysObj_Core
   ObjectCache cache;
 
   std::shared_ptr<RGWSI_SysObj_Cache_CB> cb;
-  rgw::sal::ConfigStore *cfgstore{nullptr};
 
   void normalize_pool_and_obj(const rgw_pool& src_pool, const std::string& src_obj, rgw_pool& dst_pool, std::string& dst_obj);
 protected:
index 84de5141ccae769369bfa40ca3fb67f76db600e4..9461abc93385ea1f97ecc8aa4ff3103ee441a80a 100755 (executable)
@@ -12,6 +12,7 @@
 #include "rgw_aio_throttle.h"
 #include "rgw_sal.h"
 #include "rgw_sal_store.h"
+#include "rgw_sal_config.h"
 #include "driver/dbstore/common/dbstore.h"
 #include "rgw_sal_d4n.h"
 #include "rgw_sal_filter.h"
@@ -115,9 +116,11 @@ class D4NFilterFixture: public ::testing::Test {
       DriverManager::Config cfg = DriverManager::get_config(true, g_ceph_context);
       cfg.store_name = "dbstore";
       cfg.filter_name = "d4n";
+      auto config_store_type = g_conf().get_val<std::string>("rgw_config_store");
+      auto cfgstore = DriverManager::create_config_store(env->dpp, config_store_type);
 
       auto filterDriver = DriverManager::get_raw_storage(env->dpp, g_ceph_context,
-                                                         cfg, io, site_config);
+                                                         cfg, io, site_config, cfgstore.get());
 
       rgw::sal::Driver* next = filterDriver;
       driver = newD4NFilter(next, io);