]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/main: init_storage() creates a ConfigStore and loads SiteConfig
authorCasey Bodley <cbodley@redhat.com>
Thu, 13 Oct 2022 19:09:54 +0000 (15:09 -0400)
committerCasey Bodley <cbodley@redhat.com>
Sun, 12 Mar 2023 23:05:22 +0000 (19:05 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_appmain.cc
src/rgw/rgw_main.cc
src/rgw/rgw_main.h
src/rgw/rgw_process_env.h

index 64c3258a54b38f713293c3d3670fe9b55ae1dc90..82c504901afa350fd02221ea604840f467a21a5b 100644 (file)
@@ -27,7 +27,8 @@
 #include "include/stringify.h"
 #include "rgw_main.h"
 #include "rgw_common.h"
-#include "rgw_sal_rados.h"
+#include "rgw_sal.h"
+#include "rgw_sal_config.h"
 #include "rgw_period_pusher.h"
 #include "rgw_realm_reloader.h"
 #include "rgw_rest.h"
@@ -91,6 +92,11 @@ namespace {
 
 OpsLogFile* rgw::AppMain::ops_log_file;
 
+rgw::AppMain::AppMain(const DoutPrefixProvider* dpp) : dpp(dpp)
+{
+}
+rgw::AppMain::~AppMain() = default;
+
 void rgw::AppMain::init_frontends1(bool nfs) 
 {
   this->nfs = nfs;
@@ -196,9 +202,22 @@ void rgw::AppMain::init_numa()
   }
 } /* init_numa */
 
-void rgw::AppMain::init_storage()
+int rgw::AppMain::init_storage()
 {
-    auto run_gc =
+  auto config_store_type = g_conf().get_val<std::string>("rgw_config_store");
+  cfgstore = DriverManager::create_config_store(dpp, config_store_type);
+  if (!cfgstore) {
+    return -EIO;
+  }
+  env.cfgstore = cfgstore.get();
+
+  int r = site.load(dpp, null_yield, cfgstore.get());
+  if (r < 0) {
+    return r;
+  }
+  env.site = &site;
+
+  auto run_gc =
     (g_conf()->rgw_enable_gc_threads &&
       ((!nfs) || (nfs && g_conf()->rgw_nfs_run_gc_threads)));
 
@@ -224,7 +243,10 @@ void rgw::AppMain::init_storage()
           g_conf().get_val<bool>("rgw_dynamic_resharding"),
           true, // run notification thread
           g_conf()->rgw_cache_enabled);
-
+  if (!env.driver) {
+    return -EIO;
+  }
+  return 0;
 } /* init_storage */
 
 void rgw::AppMain::init_perfcounters()
@@ -586,6 +608,7 @@ void rgw::AppMain::shutdown(std::function<void(void)> finalize_async_signals)
     lua_background->shutdown();
   }
 
+  cfgstore.reset(); // deletes
   DriverManager::close_storage(env.driver);
 
   rgw_tools_cleanup();
index 6d26302516db8be37a176116b4d4dc9583d40ec8..27b02f841951db1941bdd61143b8478f75f764ef 100644 (file)
@@ -135,15 +135,15 @@ int main(int argc, char *argv[])
   main.init_perfcounters();
   main.init_http_clients();
 
-  main.init_storage();
-  if (! main.get_driver()) {
+  r = main.init_storage();
+  if (r < 0) {
     mutex.lock();
     init_timer.cancel_all_events();
     init_timer.shutdown();
     mutex.unlock();
 
     derr << "Couldn't init storage provider (RADOS)" << dendl;
-    return EIO;
+    return -r;
   }
 
   main.cond_init_apis();
index 149a61f44095464d0876a0abc13c7cd0a0c898fd..49846c5d595a01a7c93d4f9b797639f08b758039 100644 (file)
@@ -51,6 +51,7 @@ public:
 namespace rgw {
 
 namespace lua { class Background; }
+namespace sal { class ConfigStore; }
 
 class RGWLib;
 class AppMain {
@@ -76,17 +77,21 @@ class AppMain {
   std::unique_ptr<RGWFrontendPauser> fe_pauser;
   std::unique_ptr<RGWRealmWatcher> realm_watcher;
   std::unique_ptr<RGWPauser> rgw_pauser;
-  DoutPrefixProvider* dpp;
+  std::unique_ptr<sal::ConfigStore> cfgstore;
+  SiteConfig site;
+  const DoutPrefixProvider* dpp;
   RGWProcessEnv env;
 
 public:
-  AppMain(DoutPrefixProvider* dpp)
-    : dpp(dpp)
-    {}
+  AppMain(const DoutPrefixProvider* dpp);
+  ~AppMain();
 
   void shutdown(std::function<void(void)> finalize_async_signals
               = []() { /* nada */});
 
+  sal::ConfigStore* get_config_store() const {
+    return cfgstore.get();
+  }
   rgw::sal::Driver* get_driver() {
     return env.driver;
   }
@@ -97,7 +102,7 @@ public:
 
   void init_frontends1(bool nfs = false);
   void init_numa();
-  void init_storage();
+  int init_storage();
   void init_perfcounters();
   void init_http_clients();
   void cond_init_apis();
index 4becf21a10fe2b0069b860f7c9e56334508a1dfa..905c0a5411c1b8759e18cf028a5cd90d4ffe466d 100644 (file)
@@ -9,6 +9,9 @@ class ActiveRateLimiter;
 class OpsLogSink;
 class RGWREST;
 
+namespace rgw {
+  class SiteConfig;
+}
 namespace rgw::auth {
   class StrategyRegistry;
 }
@@ -16,7 +19,8 @@ namespace rgw::lua {
   class Background;
 }
 namespace rgw::sal {
-  class Store;
+  class ConfigStore;
+  class Driver;
   class LuaManager;
 }
 
@@ -35,7 +39,9 @@ struct RGWLuaProcessEnv {
 
 struct RGWProcessEnv {
   RGWLuaProcessEnv lua;
+  rgw::sal::ConfigStore* cfgstore = nullptr;
   rgw::sal::Driver* driver = nullptr;
+  rgw::SiteConfig* site = nullptr;
   RGWREST *rest = nullptr;
   OpsLogSink *olog = nullptr;
   std::unique_ptr<rgw::auth::StrategyRegistry> auth_registry;