From 0c50cecb29f6b7e554703c61061d0bb3066c3af4 Mon Sep 17 00:00:00 2001 From: Daniel Gryniewicz Date: Thu, 21 Apr 2022 11:45:44 -0400 Subject: [PATCH] RGW - Allow starting RGW/dbstore without connecting to Mons DBStore, and some other Stores like Motr, don't need to connect to the Mons to work. However, startup automatically connects to the mons. There's provision to not connect, but the split isn't quite right. We need to call global_pre_init() to get config from the file, to determine which store to start, but we then need to decide before calling global_init() whether the configured store needs to connect to the mons. This requires a slight change to global_init() to set no_mon_config from the new flags. Signed-off-by: Daniel Gryniewicz --- src/global/global_init.cc | 4 ++++ src/rgw/librgw.cc | 9 ++++----- src/rgw/rgw_common.cc | 24 ++++++++++++++++++++++++ src/rgw/rgw_common.h | 6 ++++++ src/rgw/rgw_main.cc | 5 +++-- src/rgw/rgw_sal_dbstore.cc | 2 +- 6 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/global/global_init.cc b/src/global/global_init.cc index d74a0f4d2f27a..f418b7b4c2f27 100644 --- a/src/global/global_init.cc +++ b/src/global/global_init.cc @@ -198,6 +198,10 @@ global_init(const std::map *defaults, // manually. If they have, update them. if (g_ceph_context->get_init_flags() != flags) { g_ceph_context->set_init_flags(flags); + if (flags & (CINIT_FLAG_NO_DEFAULT_CONFIG_FILE| + CINIT_FLAG_NO_MON_CONFIG)) { + g_conf()->no_mon_config = true; + } } #ifndef _WIN32 diff --git a/src/rgw/librgw.cc b/src/rgw/librgw.cc index 1ebd668685584..7e3068c382ea2 100644 --- a/src/rgw/librgw.cc +++ b/src/rgw/librgw.cc @@ -25,7 +25,6 @@ #include "include/str_list.h" #include "include/stringify.h" -#include "global/global_init.h" #include "global/signal_handler.h" #include "common/config.h" #include "common/errno.h" @@ -502,10 +501,10 @@ namespace rgw { { "log_file", "/var/log/radosgw/$cluster-$name.log" } }; - cct = global_init(&defaults, args, - CEPH_ENTITY_TYPE_CLIENT, - CODE_ENVIRONMENT_DAEMON, - CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS); + cct = rgw_global_init(&defaults, args, + CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_DAEMON, + CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS); ceph::mutex mutex = ceph::make_mutex("main"); SafeTimer init_timer(g_ceph_context, mutex); diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index d2f1ed918a178..fa8bd1c8f8abb 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -19,6 +19,7 @@ #include "rgw_arn.h" #include "rgw_data_sync.h" +#include "global/global_init.h" #include "common/ceph_crypto.h" #include "common/armor.h" #include "common/errno.h" @@ -2969,3 +2970,26 @@ int rgw_bucket_parse_bucket_instance(const string& bucket_instance, string *buck return 0; } + +boost::intrusive_ptr +rgw_global_init(const std::map *defaults, + std::vector < const char* >& args, + uint32_t module_type, code_environment_t code_env, + int flags) +{ + // Load the config from the files, but not the mon + global_pre_init(defaults, args, module_type, code_env, flags); + + // Get the store backend + const auto& config_store = g_conf().get_val("rgw_backend_store"); + + cerr << "config_store: " << config_store << std::endl; + if ((config_store == "dbstore") || + (config_store == "motr")) { + // These stores don't use the mon + flags |= CINIT_FLAG_NO_MON_CONFIG; + } + + // Finish global init, indicating we already ran pre-init + return global_init(defaults, args, module_type, code_env, flags, false); +} diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 702ce96512afd..7bef077f1bbba 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -2412,3 +2412,9 @@ int decode_bl(bufferlist& bl, T& t) } extern int rgw_bucket_parse_bucket_instance(const std::string& bucket_instance, std::string *bucket_name, std::string *bucket_id, int *shard_id); + +boost::intrusive_ptr +rgw_global_init(const std::map *defaults, + std::vector < const char* >& args, + uint32_t module_type, code_environment_t code_env, + int flags); diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index 24930bb896d98..f2fc502a70fb9 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -227,8 +227,8 @@ int radosgw_Main(int argc, const char **argv) // privileged ports flags |= CINIT_FLAG_DEFER_DROP_PRIVILEGES; - auto cct = global_init(&defaults, args, CEPH_ENTITY_TYPE_CLIENT, - CODE_ENVIRONMENT_DAEMON, flags); + auto cct = rgw_global_init(&defaults, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_DAEMON, flags); // First, let's determine which frontends are configured. list frontends; @@ -361,6 +361,7 @@ int radosgw_Main(int argc, const char **argv) std::string rgw_store = (!rgw_d3n_datacache_enabled) ? "rados" : "d3n"; + // Get the store backend const auto& config_store = g_conf().get_val("rgw_backend_store"); #ifdef WITH_RADOSGW_DBSTORE if (config_store == "dbstore") { diff --git a/src/rgw/rgw_sal_dbstore.cc b/src/rgw/rgw_sal_dbstore.cc index e0b0aa3224a22..8cdf3a11032de 100644 --- a/src/rgw/rgw_sal_dbstore.cc +++ b/src/rgw/rgw_sal_dbstore.cc @@ -1908,7 +1908,7 @@ namespace rgw::sal { int DBStore::get_config_key_val(string name, bufferlist *bl) { - return 0; + return -ENOTSUP; } int DBStore::meta_list_keys_init(const DoutPrefixProvider *dpp, const string& section, const string& marker, void** phandle) -- 2.39.5