From 4d1a039772e249e3df99af3ba37b2eab7fcbf73a Mon Sep 17 00:00:00 2001 From: Daniel Gryniewicz Date: Wed, 27 Apr 2022 14:02:30 -0400 Subject: [PATCH] RGW - Allow radosgw-admin to work on other stores For debugging purposes, allow radosgw-admin to run with stores other than RadosStore. Many operations will still fail (by crashing), so care must be taken when running this way. Signed-off-by: Daniel Gryniewicz --- src/rgw/rgw_admin.cc | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 08054c9f77c..ce7e6f3c22e 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -28,8 +28,6 @@ extern "C" { #include "cls/rgw/cls_rgw_types.h" #include "cls/rgw/cls_rgw_client.h" -#include "global/global_init.h" - #include "include/utime.h" #include "include/str_list.h" @@ -3370,8 +3368,8 @@ int main(int argc, const char **argv) exit(0); } - auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, - CODE_ENVIRONMENT_UTILITY, 0); + auto cct = rgw_global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, + CODE_ENVIRONMENT_UTILITY, 0); // for region -> zonegroup conversion (must happen before common_init_finish()) if (!g_conf()->rgw_region.empty() && g_conf()->rgw_zonegroup.empty()) { @@ -4246,12 +4244,36 @@ int main(int argc, const char **argv) bool need_cache = readonly_ops_list.find(opt_cmd) == readonly_ops_list.end(); bool need_gc = (gc_ops_list.find(opt_cmd) != gc_ops_list.end()) && !bypass_gc; + std::string rgw_store = "rados"; + // Get the store backend + const auto& config_store = g_conf().get_val("rgw_backend_store"); +#ifdef WITH_RADOSGW_DBSTORE + if (config_store == "dbstore") { + rgw_store = "dbstore"; + } +#endif + +#ifdef WITH_RADOSGW_MOTR + if (config_store == "motr") { + rgw_store = "motr"; + } +#endif + if (raw_storage_op) { - store = StoreManager::get_raw_storage(dpp(), g_ceph_context, "rados"); + store = StoreManager::get_raw_storage(dpp(), + g_ceph_context, + rgw_store); } else { - store = StoreManager::get_storage(dpp(), g_ceph_context, "rados", false, false, false, - false, false, - need_cache && g_conf()->rgw_cache_enabled, need_gc); + store = StoreManager::get_storage(dpp(), + g_ceph_context, + rgw_store, + false, + false, + false, + false, + false, + need_cache && g_conf()->rgw_cache_enabled, + need_gc); } if (!store) { cerr << "couldn't init storage provider" << std::endl;