From 7e36bd5c8f8a1d74c724ed8e1d6de61749290a65 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 13 Oct 2022 15:09:54 -0400 Subject: [PATCH] rgw/main: init_storage() creates a ConfigStore and loads SiteConfig Signed-off-by: Casey Bodley --- src/rgw/rgw_appmain.cc | 31 +++++++++++++++++++++++++++---- src/rgw/rgw_main.cc | 6 +++--- src/rgw/rgw_main.h | 15 ++++++++++----- src/rgw/rgw_process_env.h | 8 +++++++- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/src/rgw/rgw_appmain.cc b/src/rgw/rgw_appmain.cc index 64c3258a54b38..82c504901afa3 100644 --- a/src/rgw/rgw_appmain.cc +++ b/src/rgw/rgw_appmain.cc @@ -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("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("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 finalize_async_signals) lua_background->shutdown(); } + cfgstore.reset(); // deletes DriverManager::close_storage(env.driver); rgw_tools_cleanup(); diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index 6d26302516db8..27b02f841951d 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -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(); diff --git a/src/rgw/rgw_main.h b/src/rgw/rgw_main.h index 149a61f440954..49846c5d595a0 100644 --- a/src/rgw/rgw_main.h +++ b/src/rgw/rgw_main.h @@ -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 fe_pauser; std::unique_ptr realm_watcher; std::unique_ptr rgw_pauser; - DoutPrefixProvider* dpp; + std::unique_ptr cfgstore; + SiteConfig site; + const DoutPrefixProvider* dpp; RGWProcessEnv env; public: - AppMain(DoutPrefixProvider* dpp) - : dpp(dpp) - {} + AppMain(const DoutPrefixProvider* dpp); + ~AppMain(); void shutdown(std::function 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(); diff --git a/src/rgw/rgw_process_env.h b/src/rgw/rgw_process_env.h index 4becf21a10fe2..905c0a5411c1b 100644 --- a/src/rgw/rgw_process_env.h +++ b/src/rgw/rgw_process_env.h @@ -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 auth_registry; -- 2.39.5