extern "C" {
-void* newRadosStore(void* io_context)
+void* newRadosStore(void* io_context, const void* site_config)
{
rgw::sal::RadosStore* store = new rgw::sal::RadosStore(
- *static_cast<boost::asio::io_context*>(io_context));
+ *static_cast<boost::asio::io_context*>(io_context),
+ *static_cast<const rgw::SiteConfig*>(site_config));
if (store) {
RGWRados* rados = new RGWRados();
class RadosStore : public StoreDriver {
private:
boost::asio::io_context& io_context;
+ const rgw::SiteConfig& site_config;
RGWRados* rados;
RGWUserCtl* user_ctl;
std::unique_ptr<RadosZone> zone;
std::string topics_oid(const std::string& tenant) const;
public:
- RadosStore(boost::asio::io_context& io_context)
- : io_context(io_context), rados(nullptr) {
+ RadosStore(boost::asio::io_context& io_context,
+ const rgw::SiteConfig& site_config)
+ : io_context(io_context), site_config(site_config), rados(nullptr) {
}
~RadosStore() {
delete rados;
void setRados(RGWRados * st) { rados = st; }
RGWRados* getRados(void) { return rados; }
boost::asio::io_context& get_io_context() { return io_context; }
+ const rgw::SiteConfig& get_siteconfig() { return site_config; }
neorados::RADOS& get_neorados() { return *neorados; }
RGWServices* svc() { return &rados->svc; }
}
int SiteConfig::load(const DoutPrefixProvider* dpp, optional_yield y,
- sal::ConfigStore* cfgstore)
+ sal::ConfigStore* cfgstore, bool force_local_zonegroup)
{
// clear existing configuration
zone = nullptr;
}
}
- if (realm) {
+ if (realm && !force_local_zonegroup) {
// try to load the realm's period
r = load_period_zonegroup(dpp, y, cfgstore, *realm, zone_params.id);
} else {
return r;
}
+std::unique_ptr<SiteConfig> SiteConfig::make_fake() {
+ auto fake = std::make_unique<SiteConfig>();
+ fake->local_zonegroup.emplace();
+ fake->local_zonegroup->zones.emplace(""s, RGWZone{});
+ fake->zonegroup = &*fake->local_zonegroup;
+ fake->zone = &fake->zonegroup->zones.begin()->second;
+ return fake;
+}
+
int SiteConfig::load_period_zonegroup(const DoutPrefixProvider* dpp,
optional_yield y,
sal::ConfigStore* cfgstore,
/// Load or reload the multisite configuration from storage. This is not
/// thread-safe, so requires careful coordination with the RGWRealmReloader.
int load(const DoutPrefixProvider* dpp, optional_yield y,
- sal::ConfigStore* cfgstore);
+ sal::ConfigStore* cfgstore, bool force_local_zonegroup = false);
+
+ /// Create a fake site config to be used by tests and similar, just
+ /// to have a site config.
+ ///
+ /// \warning Do not use this anywhere but unittests where we need to
+ /// bring up parts of RGW that require a SiteConfig exist, but need
+ /// to run without a cluster.
+ static std::unique_ptr<SiteConfig> make_fake();
+
+ virtual ~SiteConfig() = default;
private:
int load_period_zonegroup(const DoutPrefixProvider* dpp, optional_yield y,
const RGWZone* zone = nullptr;
};
+
} // namespace rgw
static rgw::sal::Driver* driver = NULL;
static constexpr auto dout_subsys = ceph_subsys_rgw;
-
static const DoutPrefixProvider* dpp() {
struct GlobalPrefix : public DoutPrefixProvider {
CephContext *get_cct() const override { return dout_context; }
// not a raw op if 'period pull' needs to read zone/period configuration
bool raw_period_pull = opt_cmd == OPT::PERIOD_PULL && !url.empty();
+ // Before a period commit or pull, our zonegroup may not be in the
+ // period, causing `load_period_zonegroup` to fail.
+ bool localzonegroup_op = ((opt_cmd == OPT::PERIOD_UPDATE && commit) ||
+ (opt_cmd == OPT::PERIOD_PULL && url.empty()));
+
std::set<OPT> raw_storage_ops_list = {OPT::ZONEGROUP_ADD, OPT::ZONEGROUP_CREATE,
OPT::ZONEGROUP_DELETE,
OPT::ZONEGROUP_GET, OPT::ZONEGROUP_LIST,
return EIO;
}
+ std::unique_ptr<rgw::SiteConfig> site;
+
if (raw_storage_op) {
+ site = rgw::SiteConfig::make_fake();
driver = DriverManager::get_raw_storage(dpp(), g_ceph_context,
- cfg, context_pool);
+ cfg, context_pool, *site);
} else {
+ site = std::make_unique<rgw::SiteConfig>();
+ auto r = site->load(dpp(), null_yield, cfgstore.get(), localzonegroup_op);
+ if (r < 0) {
+ std::cerr << "Unable to initialize site config." << std::endl;
+ exit(1);
+ }
+
driver = DriverManager::get_storage(dpp(),
g_ceph_context,
cfg,
context_pool,
+ *site,
false,
false,
false,
env.driver = DriverManager::get_storage(dpp, dpp->get_cct(),
cfg,
*context_pool,
+ site,
run_gc,
run_lc,
run_quota,
#include "rgw_formats.h"
#include "rgw_usage.h"
#include "rgw_object_expirer_core.h"
+#include "driver/rados/rgw_zone.h"
+#include "rgw_sal_config.h"
#define dout_subsys ceph_subsys_rgw
DriverManager::Config cfg;
cfg.store_name = "rados";
cfg.filter_name = "none";
- driver = DriverManager::get_storage(&dp, g_ceph_context, cfg, context_pool, false, false, false, false, false, false, null_yield);
+ std::unique_ptr<rgw::sal::ConfigStore> cfgstore;
+ auto config_store_type = g_conf().get_val<std::string>("rgw_config_store");
+ cfgstore = DriverManager::create_config_store(&dp, config_store_type);
+ if (!cfgstore) {
+ std::cerr << "Unable to initialize config store." << std::endl;
+ exit(1);
+ }
+ rgw::SiteConfig site;
+ auto r = site.load(&dp, null_yield, cfgstore.get());
+ if (r < 0) {
+ std::cerr << "Unable to initialize config store." << std::endl;
+ exit(1);
+ }
+
+ driver = DriverManager::get_storage(&dp, g_ceph_context, cfg, context_pool, site, false, false, false, false, false, false, null_yield);
if (!driver) {
std::cerr << "couldn't init storage provider" << std::endl;
return EIO;
cfg.store_name = "rados";
cfg.filter_name = "none";
env.driver = DriverManager::get_storage(&dp, cct, cfg, io_context,
+ *env.site,
cct->_conf->rgw_enable_gc_threads,
cct->_conf->rgw_enable_lc_threads,
cct->_conf->rgw_enable_quota_threads,
#define dout_subsys ceph_subsys_rgw
extern "C" {
-extern rgw::sal::Driver* newRadosStore(boost::asio::io_context* io_context);
+extern rgw::sal::Driver* newRadosStore(boost::asio::io_context* io_context,
+ const rgw::SiteConfig* site_config);
#ifdef WITH_RADOSGW_DBSTORE
extern rgw::sal::Driver* newDBStore(CephContext *cct);
#endif
CephContext* cct,
const Config& cfg,
boost::asio::io_context& io_context,
+ const rgw::SiteConfig& site_config,
bool use_gc_thread,
bool use_lc_thread,
bool quota_threads,
rgw::sal::Driver* driver{nullptr};
if (cfg.store_name.compare("rados") == 0) {
- driver = newRadosStore(&io_context);
+ driver = newRadosStore(&io_context, &site_config);
RGWRados* rados = static_cast<rgw::sal::RadosStore* >(driver)->getRados();
if ((*rados).set_use_cache(use_cache)
}
}
else if (cfg.store_name.compare("d3n") == 0) {
- driver = new rgw::sal::RadosStore(io_context);
+ driver = new rgw::sal::RadosStore(io_context, site_config);
RGWRados* rados = new D3nRGWDataCache<RGWRados>;
dynamic_cast<rgw::sal::RadosStore*>(driver)->setRados(rados);
rados->set_store(static_cast<rgw::sal::RadosStore* >(driver));
return driver;
}
-rgw::sal::Driver* DriverManager::init_raw_storage_provider(const DoutPrefixProvider* dpp, CephContext* cct, const Config& cfg, boost::asio::io_context& io_context)
+rgw::sal::Driver* DriverManager::init_raw_storage_provider(const DoutPrefixProvider* dpp, CephContext* cct,
+ const Config& cfg, boost::asio::io_context& io_context,
+ const rgw::SiteConfig& site_config)
{
rgw::sal::Driver* driver = nullptr;
if (cfg.store_name.compare("rados") == 0) {
- driver = newRadosStore(&io_context);
+ driver = newRadosStore(&io_context, &site_config);
RGWRados* rados = static_cast<rgw::sal::RadosStore* >(driver)->getRados();
rados->set_context(cct);
CephContext* cct,
const Config& cfg,
boost::asio::io_context& io_context,
+ const rgw::SiteConfig& site_config,
bool use_gc_thread,
bool use_lc_thread,
bool quota_threads,
bool run_notification_thread, optional_yield y,
bool use_cache = true,
bool use_gc = true) {
- rgw::sal::Driver* driver = init_storage_provider(dpp, cct, cfg, io_context, use_gc_thread,
+ rgw::sal::Driver* driver = init_storage_provider(dpp, cct, cfg, io_context,
+ site_config,
+ use_gc_thread,
use_lc_thread,
quota_threads,
run_sync_thread,
/** Get a stripped down driver by service name */
static rgw::sal::Driver* get_raw_storage(const DoutPrefixProvider* dpp,
CephContext* cct, const Config& cfg,
- boost::asio::io_context& io_context) {
- rgw::sal::Driver* driver = init_raw_storage_provider(dpp, cct, cfg, io_context);
+ boost::asio::io_context& io_context,
+ const rgw::SiteConfig& site_config) {
+ rgw::sal::Driver* driver = init_raw_storage_provider(dpp, cct, cfg,
+ io_context,
+ site_config);
return driver;
}
/** Initialize a new full Driver */
CephContext* cct,
const Config& cfg,
boost::asio::io_context& io_context,
+ const rgw::SiteConfig& site_config,
bool use_gc_thread,
bool use_lc_thread,
bool quota_threads,
static rgw::sal::Driver* init_raw_storage_provider(const DoutPrefixProvider* dpp,
CephContext* cct,
const Config& cfg,
- boost::asio::io_context& io_context);
+ boost::asio::io_context& io_context,
+ const rgw::SiteConfig& site_config);
/** Close a Driver when it's no longer needed */
static void close_storage(rgw::sal::Driver* driver);
#include "rgw_cr_rados.h"
#include "rgw_sal.h"
#include "rgw_sal_rados.h"
+#include "driver/rados/rgw_zone.h"
+#include "rgw_sal_config.h"
#include "gtest/gtest.h"
ceph::async::io_context_pool context_pool{cct->_conf->rgw_thread_pool_size};
DriverManager::Config cfg = DriverManager::get_config(true, g_ceph_context);
+ auto config_store_type = g_conf().get_val<std::string>("rgw_config_store");
+ std::unique_ptr<rgw::sal::ConfigStore> cfgstore
+ = DriverManager::create_config_store(dpp(), config_store_type);
+ if (!cfgstore) {
+ std::cerr << "Unable to initialize config store." << std::endl;
+ exit(1);
+ }
+ rgw::SiteConfig site;
+ auto r = site.load(dpp(), null_yield, cfgstore.get());
+ if (r < 0) {
+ std::cerr << "Unable to initialize config store." << std::endl;
+ exit(1);
+ }
store = static_cast<rgw::sal::RadosStore*>(
DriverManager::get_storage(dpp(),
g_ceph_context,
cfg,
context_pool,
+ site,
false,
false,
false,
#include "rgw_sal.h"
#include "rgw_auth.h"
#include "rgw_auth_registry.h"
+#include "driver/rados/rgw_zone.h"
+#include "rgw_sal_config.h"
#include <boost/asio/io_context.hpp>
cct = global_init(nullptr, args, CEPH_ENTITY_TYPE_CLIENT,
CODE_ENVIRONMENT_UTILITY,
CINIT_FLAG_NO_MON_CONFIG);
-
+
dpp = new DoutPrefix(cct->get(), dout_subsys, "d4n test: ");
DriverManager::Config cfg;
cfg.store_name = "dbstore";
cfg.filter_name = "d4n";
-
+ auto config_store_type = g_conf().get_val<std::string>("rgw_config_store");
+ std::unique_ptr<rgw::sal::ConfigStore> cfgstore
+ = DriverManager::create_config_store(dpp, config_store_type);
+ ASSERT_TRUE(cfgstore);
+ rgw::SiteConfig site;
+ auto r = site.load(dpp, null_yield, cfgstore.get());
+ ASSERT_GT(r, 0);
+
driver = DriverManager::get_storage(dpp, dpp->get_cct(),
cfg,
ioc,
+ site,
false,
false,
false,
void test_rgw_init_bucket(rgw_bucket *bucket, const char *name);
rgw_obj test_rgw_create_obj(const rgw_bucket& bucket, const std::string& name, const std::string& instance, const std::string& ns);
+
+
#endif
#include "rgw_op.h"
#include "rgw_process_env.h"
#include "rgw_sal_rados.h"
-
+#include "driver/rados/rgw_zone.h"
+#include "rgw_sal_config.h"
using std::string;
-using std::vector;
using boost::container::flat_set;
using boost::intrusive_ptr;
-using boost::make_optional;
using boost::none;
using rgw::auth::Identity;
// Unfortunately RGWCivetWeb is too tightly tied to civetweb to test RGWCivetWeb::init_env.
RGWEnv rgw_env;
ceph::async::io_context_pool context_pool(cct->_conf->rgw_thread_pool_size); \
- rgw::sal::RadosStore store(context_pool);
+ auto site = rgw::SiteConfig::make_fake();
+ rgw::sal::RadosStore store(context_pool, *site);
std::unique_ptr<rgw::sal::User> user = store.get_user(rgw_user());
rgw_env.set("REMOTE_ADDR", "192.168.1.1");
rgw_env.set("HTTP_HOST", "1.2.3.4");
#include "rgw_lua_request.h"
#include "rgw_lua_background.h"
#include "rgw_lua_data_filter.h"
+#include "driver/rados/rgw_zone.h"
+#include "rgw_sal_config.h"
using namespace std;
using namespace rgw;
tracing::Tracer tracer;
-#define MAKE_STORE \
- ceph::async::io_context_pool context_pool(g_cct->_conf->rgw_thread_pool_size); \
- auto store = std::unique_ptr<sal::RadosStore>(new sal::RadosStore(context_pool)); \
- store->setRados(new RGWRados);
+inline std::unique_ptr<sal::RadosStore> make_store() {
+ auto context_pool = std::make_unique<ceph::async::io_context_pool>(
+ g_cct->_conf->rgw_thread_pool_size);
+ std::unique_ptr<rgw::SiteConfig> site = rgw::SiteConfig::make_fake();
+
+
+ struct StoreBundle : public sal::RadosStore {
+ std::unique_ptr<ceph::async::io_context_pool> context_pool;
+ std::unique_ptr<rgw::SiteConfig> site;
+ StoreBundle(std::unique_ptr<ceph::async::io_context_pool> context_pool_,
+ std::unique_ptr<rgw::SiteConfig> site_)
+ : sal::RadosStore(*context_pool_.get(), *site_),
+ context_pool(std::move(context_pool_)),
+ site(std::move(site_)) {
+ setRados(new RGWRados);
+ }
+ virtual ~StoreBundle() = default;
+ };
+ return std::make_unique<StoreBundle>(std::move(context_pool),
+ std::move(site));
+};
#define DEFINE_REQ_STATE RGWProcessEnv pe; \
- MAKE_STORE; \
+ auto store = make_store(); \
pe.lua.manager = store->get_lua_manager(""); \
RGWEnv e; \
req_state s(g_cct, pe, &e, 0);
TEST(TestRGWLuaBackground, Start)
{
- MAKE_STORE;
+ auto store = make_store();
auto manager = store->get_lua_manager("");
{
// ctr and dtor without running
RGW[key] = value
)";
- MAKE_STORE;
+ auto store = make_store();
auto manager = store->get_lua_manager("");
TestBackground lua_background(store.get(), script, manager.get());
lua_background.start();
end
)";
- MAKE_STORE;
+ auto store = make_store();
auto manager = store->get_lua_manager("");
TestBackground lua_background(store.get(), script, manager.get());
lua_background.start();
end
)";
- MAKE_STORE;
+ auto store = make_store();
auto manager = store->get_lua_manager("");
TestBackground lua_background(store.get(), script, manager.get(), 2);
lua_background.start();
RGW[key] = value
)";
- MAKE_STORE;
+ auto store = make_store();
auto manager = store->get_lua_manager("");
TestBackground lua_background(store.get(), script, manager.get());
lua_background.pause();
end
)";
- MAKE_STORE;
+ auto store = make_store();
auto manager = store->get_lua_manager("");
TestBackground lua_background(store.get(), script, manager.get());
lua_background.start();
end
)";
- MAKE_STORE;
+ auto store = make_store();
auto manager = store->get_lua_manager("");
TestBackground lua_background(store.get(), script, manager.get());
lua_background.start();