]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
RGW - Allow starting RGW/dbstore without connecting to Mons
authorDaniel Gryniewicz <dang@redhat.com>
Thu, 21 Apr 2022 15:45:44 +0000 (11:45 -0400)
committerDaniel Gryniewicz <dang@redhat.com>
Wed, 27 Apr 2022 18:04:36 +0000 (14:04 -0400)
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 <dang@redhat.com>
src/global/global_init.cc
src/rgw/librgw.cc
src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_main.cc
src/rgw/rgw_sal_dbstore.cc

index d74a0f4d2f27a646be7a51858d751cdae75f0e31..f418b7b4c2f27ad6a49bc383ff2db17d98ec9374 100644 (file)
@@ -198,6 +198,10 @@ global_init(const std::map<std::string,std::string> *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
index 1ebd668685584e33694fd3a2ab122ae458fded4f..7e3068c382ea29d86acd14fb971e39bbdfb3bfdc 100644 (file)
@@ -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);
index d2f1ed918a1786e6074f2027c6928a3abe60ad0a..fa8bd1c8f8abbaf0dc6b7ec1e01a5946e6ad2863 100644 (file)
@@ -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<CephContext>
+rgw_global_init(const std::map<std::string,std::string> *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<std::string>("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);
+}
index 702ce96512afdd60a7458cd846e579c80af830e2..7bef077f1bbbacaca0eaea4fcc326a9df83b644a 100644 (file)
@@ -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<CephContext>
+rgw_global_init(const std::map<std::string,std::string> *defaults,
+                   std::vector < const char* >& args,
+                   uint32_t module_type, code_environment_t code_env,
+                   int flags);
index 24930bb896d985a28f4b7f3e22e6108005b646db..f2fc502a70fb9ed6cbe7545d2ef8a41758785858 100644 (file)
@@ -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<string> 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<std::string>("rgw_backend_store");
 #ifdef WITH_RADOSGW_DBSTORE
   if (config_store == "dbstore") {
index e0b0aa3224a2212339753984dfe67c0a291a8b3c..8cdf3a11032de06fb567adcc333c7205f207b370 100644 (file)
@@ -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)