RGW/standalone: Build without RadosStore

Signed-off-by: Ali Masarwa <amasarwa@redhat.com>
This commit is contained in:
Ali Masarwa 2025-05-06 11:17:48 +03:00
parent 7c89819f00
commit 71799fb6f3
27 changed files with 1642 additions and 1640 deletions

View File

@ -553,6 +553,7 @@ option(WITH_RADOSGW_MOTR "CORTX-Motr backend for RADOS Gateway" OFF)
option(WITH_RADOSGW_DAOS "DAOS backend for RADOS Gateway" OFF)
option(WITH_RADOSGW_D4N "D4N wrapper for RADOS Gateway" ON)
option(WITH_RADOSGW_POSIX "POSIX backend for RADOS Gateway" ON)
option(WITH_RADOSGW_RADOS "RADOS backend for Rados Gateway" ON)
option(WITH_RADOSGW_SELECT_PARQUET "Support for s3 select on parquet objects" ON)
option(WITH_RADOSGW_ARROW_FLIGHT "Build arrow flight when not using system-provided arrow" OFF)
option(WITH_RADOSGW_BACKTRACE_LOGGING "Enable backtraces in rgw logs" OFF)

View File

@ -366,6 +366,9 @@
/* Backend POSIX for Rados Gateway */
#cmakedefine WITH_RADOSGW_POSIX
/* Backend RADOS for Rados Gateway */
#cmakedefine WITH_RADOSGW_RADOS
/* Defined if std::map::merge() is supported */
#cmakedefine HAVE_STDLIB_MAP_SPLICING

View File

@ -36,26 +36,6 @@ endfunction()
find_package(ICU 52.0 COMPONENTS uc REQUIRED)
set(librgw_common_srcs
services/svc_finisher.cc
services/svc_bi_rados.cc
services/svc_bilog_rados.cc
services/svc_bucket.cc
services/svc_bucket_sobj.cc
services/svc_bucket_sync_sobj.cc
services/svc_cls.cc
services/svc_config_key_rados.cc
services/svc_mdlog.cc
services/svc_notify.cc
services/svc_quota.cc
services/svc_sync_modules.cc
services/svc_sys_obj.cc
services/svc_sys_obj_cache.cc
services/svc_sys_obj_core.cc
services/svc_tier_rados.cc
services/svc_user.cc
services/svc_user_rados.cc
services/svc_zone.cc
services/svc_zone_utils.cc
spdk/crc64.c
madler/crc64nvme.c
madler/crc32iso_hdlc.c
@ -166,76 +146,97 @@ set(librgw_common_srcs
rgw_dedup_cluster.cc
rgw_data_access.cc
rgw_realm_watcher.cc
driver/rados/account.cc
driver/rados/buckets.cc
rgw_bucket_logging.cc
rgw_rest_bucket_logging.cc
driver/rados/group.cc
driver/rados/groups.cc
driver/rados/rgw_bucket.cc
driver/rados/rgw_bucket_sync.cc
driver/rados/rgw_cr_rados.cc
driver/rados/rgw_cr_tools.cc
driver/rados/rgw_d3n_datacache.cc
driver/rados/rgw_datalog.cc
driver/rados/rgw_datalog_notify.cc
driver/rados/rgw_data_sync.cc
driver/rados/rgw_etag_verifier.cc
driver/rados/rgw_gc.cc
driver/rados/rgw_gc_log.cc
driver/rados/rgw_lc_tier.cc
driver/rados/rgw_log_backing.cc
driver/rados/rgw_metadata.cc
driver/rados/rgw_notify.cc
driver/rados/rgw_obj_manifest.cc
driver/rados/rgw_object_expirer_core.cc
driver/rados/rgw_otp.cc
driver/rados/rgw_period.cc
driver/rados/rgw_pubsub_push.cc
driver/rados/rgw_putobj_processor.cc
driver/rados/rgw_rados.cc
driver/rados/rgw_reshard.cc
driver/rados/rgw_rest_bucket.cc
driver/rados/rgw_rest_log.cc
driver/rados/rgw_rest_realm.cc
driver/rados/rgw_rest_user.cc
driver/rados/rgw_sal_rados.cc
driver/rados/rgw_service.cc
driver/rados/rgw_sync.cc
driver/rados/rgw_sync_counters.cc
driver/rados/rgw_sync_error_repo.cc
driver/rados/rgw_sync_module.cc
driver/rados/rgw_sync_module_aws.cc
driver/rados/rgw_sync_module_es.cc
driver/rados/rgw_sync_module_es_rest.cc
driver/rados/rgw_sync_module_log.cc
driver/rados/rgw_sync_trace.cc
driver/rados/rgw_tools.cc
driver/rados/rgw_trim_bilog.cc
driver/rados/rgw_trim_datalog.cc
driver/rados/rgw_trim_mdlog.cc
driver/rados/rgw_user.cc
driver/rados/rgw_zone.cc
driver/rados/role.cc
driver/rados/roles.cc
driver/rados/sync_fairness.cc
driver/rados/topic.cc
driver/rados/topic_migration.cc
driver/rados/topics.cc
driver/rados/users.cc)
rgw_bucket_sync.cc)
list(APPEND librgw_common_srcs
driver/immutable_config/store.cc
driver/json_config/store.cc
driver/rados/config/impl.cc
driver/rados/config/period.cc
driver/rados/config/period_config.cc
driver/rados/config/realm.cc
driver/rados/config/realm_watcher.cc
driver/rados/config/store.cc
driver/rados/config/zone.cc
driver/rados/config/zonegroup.cc)
driver/json_config/store.cc)
if(WITH_RADOSGW_RADOS)
list(APPEND librgw_common_srcs
services/svc_finisher.cc
services/svc_bi_rados.cc
services/svc_bilog_rados.cc
services/svc_bucket.cc
services/svc_bucket_sobj.cc
services/svc_bucket_sync_sobj.cc
services/svc_cls.cc
services/svc_config_key_rados.cc
services/svc_mdlog.cc
services/svc_notify.cc
services/svc_quota.cc
services/svc_sync_modules.cc
services/svc_sys_obj.cc
services/svc_sys_obj_cache.cc
services/svc_sys_obj_core.cc
services/svc_tier_rados.cc
services/svc_user.cc
services/svc_user_rados.cc
services/svc_zone.cc
services/svc_zone_utils.cc
driver/rados/account.cc
driver/rados/buckets.cc
driver/rados/group.cc
driver/rados/groups.cc
driver/rados/rgw_bucket.cc
driver/rados/rgw_cr_rados.cc
driver/rados/rgw_cr_tools.cc
driver/rados/rgw_d3n_datacache.cc
driver/rados/rgw_datalog.cc
driver/rados/rgw_datalog_notify.cc
driver/rados/rgw_data_sync.cc
driver/rados/rgw_etag_verifier.cc
driver/rados/rgw_gc.cc
driver/rados/rgw_gc_log.cc
driver/rados/rgw_lc_tier.cc
driver/rados/rgw_log_backing.cc
driver/rados/rgw_metadata.cc
driver/rados/rgw_notify.cc
driver/rados/rgw_obj_manifest.cc
driver/rados/rgw_object_expirer_core.cc
driver/rados/rgw_otp.cc
driver/rados/rgw_pubsub_push.cc
driver/rados/rgw_putobj_processor.cc
driver/rados/rgw_rados.cc
driver/rados/rgw_reshard.cc
driver/rados/rgw_rest_bucket.cc
driver/rados/rgw_rest_log.cc
driver/rados/rgw_rest_realm.cc
driver/rados/rgw_rest_user.cc
driver/rados/rgw_sal_rados.cc
driver/rados/rgw_service.cc
driver/rados/rgw_sync.cc
driver/rados/rgw_sync_counters.cc
driver/rados/rgw_sync_error_repo.cc
driver/rados/rgw_sync_module.cc
driver/rados/rgw_sync_module_aws.cc
driver/rados/rgw_sync_module_es.cc
driver/rados/rgw_sync_module_es_rest.cc
driver/rados/rgw_sync_module_log.cc
driver/rados/rgw_sync_trace.cc
driver/rados/rgw_tools.cc
driver/rados/rgw_trim_bilog.cc
driver/rados/rgw_trim_datalog.cc
driver/rados/rgw_trim_mdlog.cc
driver/rados/rgw_user.cc
driver/rados/role.cc
driver/rados/roles.cc
driver/rados/sync_fairness.cc
driver/rados/topic.cc
driver/rados/topic_migration.cc
driver/rados/topics.cc
driver/rados/users.cc
driver/rados/config/impl.cc
driver/rados/config/period.cc
driver/rados/config/period_config.cc
driver/rados/config/realm.cc
driver/rados/config/realm_watcher.cc
driver/rados/config/store.cc
driver/rados/config/zone.cc
driver/rados/config/zonegroup.cc)
endif()
if(WITH_RADOSGW_AMQP_ENDPOINT)
list(APPEND librgw_common_srcs rgw_amqp.cc)
endif()
@ -412,10 +413,13 @@ set(rgw_a_srcs
rgw_signal.cc
rgw_swift_auth.cc
rgw_usage.cc
rgw_sts.cc
driver/rados/rgw_rest_bucket.cc
driver/rados/rgw_rest_log.cc
driver/rados/rgw_rest_realm.cc)
rgw_sts.cc)
if(WITH_RADOSGW_RADOS)
list(APPEND rgw_a_srcs driver/rados/rgw_rest_bucket.cc
driver/rados/rgw_rest_log.cc
driver/rados/rgw_rest_realm.cc)
endif()
gperf_generate(${CMAKE_SOURCE_DIR}/src/rgw/rgw_iam_policy_keywords.gperf
rgw_iam_policy_keywords.frag.cc)
@ -512,6 +516,7 @@ if(WITH_RADOSGW_ARROW_FLIGHT)
list(APPEND radosgw_admin_srcs rgw_flight.cc)
endif(WITH_RADOSGW_ARROW_FLIGHT)
if(WITH_RADOSGW_RADOS)
add_executable(radosgw-admin ${radosgw_admin_srcs})
target_link_libraries(radosgw-admin
legacy-option-headers
@ -522,6 +527,7 @@ target_link_libraries(radosgw-admin
global ${LIB_RESOLV}
OATH::OATH
${CURL_LIBRARIES} ${EXPAT_LIBRARIES} ${BLKID_LIBRARIES})
endif()
# this is unsatisfying and hopefully temporary; ARROW should not be
# part of radosgw_admin
@ -529,7 +535,9 @@ if(WITH_RADOSGW_ARROW_FLIGHT)
target_link_libraries(radosgw-admin ${ARROW_LIBRARIES} ${ARROW_FLIGHT_LIBRARIES})
endif(WITH_RADOSGW_ARROW_FLIGHT)
if(WITH_RADOSGW_RADOS)
install(TARGETS radosgw-admin DESTINATION bin)
endif()
set(radosgw_es_srcs
rgw_es_main.cc)
@ -551,6 +559,7 @@ target_link_libraries(radosgw-token
global)
install(TARGETS radosgw-token DESTINATION bin)
if(WITH_RADOSGW_RADOS)
set(radosgw_object_expirer_srcs
rgw_object_expirer.cc)
add_executable(radosgw-object-expirer ${radosgw_object_expirer_srcs})
@ -561,6 +570,7 @@ target_link_libraries(radosgw-object-expirer ${rgw_libs} librados
global ${LIB_RESOLV}
${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
install(TARGETS radosgw-object-expirer DESTINATION bin)
endif()
set(radosgw_polparser_srcs
rgw_polparser.cc)

View File

@ -27,7 +27,7 @@
#include "common/random_string.h"
#include "rgw_realm_watcher.h"
#include "driver/rados/rgw_zone.h" // FIXME: subclass dependency
#include "rgw/rgw_zone.h"
#include "common/connection_pool.h"
#include "sqlite/connection.h"

View File

@ -1,104 +0,0 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab ft=cpp
#include "rgw_sync.h"
#include "rgw_sal.h"
#include "rgw_sal_config.h"
#include "services/svc_zone.h"
#define dout_subsys ceph_subsys_rgw
using namespace std;
using namespace rgw_zone_defaults;
int RGWPeriod::get_zonegroup(RGWZoneGroup& zonegroup,
const string& zonegroup_id) const
{
map<string, RGWZoneGroup>::const_iterator iter;
if (!zonegroup_id.empty()) {
iter = period_map.zonegroups.find(zonegroup_id);
} else {
iter = period_map.zonegroups.find("default");
}
if (iter != period_map.zonegroups.end()) {
zonegroup = iter->second;
return 0;
}
return -ENOENT;
}
static int read_sync_status(const DoutPrefixProvider *dpp, rgw::sal::Driver* driver, rgw_meta_sync_status *sync_status)
{
rgw::sal::RadosStore* rados_store = static_cast<rgw::sal::RadosStore*>(driver);
// initialize a sync status manager to read the status
RGWMetaSyncStatusManager mgr(rados_store, rados_store->svc()->async_processor);
int r = mgr.init(dpp);
if (r < 0) {
return r;
}
r = mgr.read_sync_status(dpp, sync_status);
mgr.stop();
return r;
}
int RGWPeriod::update_sync_status(const DoutPrefixProvider *dpp,
rgw::sal::Driver* driver, /* for now */
const RGWPeriod &current_period,
std::ostream& error_stream,
bool force_if_stale)
{
rgw_meta_sync_status status;
int r = read_sync_status(dpp, driver, &status);
if (r < 0) {
ldpp_dout(dpp, 0) << "period failed to read sync status: "
<< cpp_strerror(-r) << dendl;
return r;
}
std::vector<std::string> markers;
const auto current_epoch = current_period.get_realm_epoch();
if (current_epoch != status.sync_info.realm_epoch) {
// no sync status markers for the current period
ceph_assert(current_epoch > status.sync_info.realm_epoch);
const int behind = current_epoch - status.sync_info.realm_epoch;
if (!force_if_stale && current_epoch > 1) {
error_stream << "ERROR: This zone is " << behind << " period(s) behind "
"the current master zone in metadata sync. If this zone is promoted "
"to master, any metadata changes during that time are likely to "
"be lost.\n"
"Waiting for this zone to catch up on metadata sync (see "
"'radosgw-admin sync status') is recommended.\n"
"To promote this zone to master anyway, add the flag "
"--yes-i-really-mean-it." << std::endl;
return -EINVAL;
}
// empty sync status markers - other zones will skip this period during
// incremental metadata sync
markers.resize(status.sync_info.num_shards);
} else {
markers.reserve(status.sync_info.num_shards);
for (auto& i : status.sync_markers) {
auto& marker = i.second;
// filter out markers from other periods
if (marker.realm_epoch != current_epoch) {
marker.marker.clear();
}
markers.emplace_back(std::move(marker.marker));
}
}
std::swap(sync_status, markers);
return 0;
}
void RGWPeriod::generate_test_instances(list<RGWPeriod*> &o)
{
RGWPeriod *z = new RGWPeriod;
o.push_back(z);
o.push_back(new RGWPeriod);
}

View File

@ -141,7 +141,7 @@ void RGWOp_Period_Post::execute(optional_yield y)
// if period id is empty, handle as 'period commit'
if (period.get_id().empty()) {
op_ret = rgw::commit_period(this, y, s->penv.cfgstore, driver, realm, *realm_writer, current_period, period, error_stream, false);
op_ret = rgw::commit_period(this, y, s->penv.cfgstore, driver, realm, *realm_writer, current_period, period, error_stream, false, *s->penv.site);
if (op_ret == -EEXIST) {
op_ret = 0; // succeed on retries so the op is idempotent
return;

View File

@ -32,33 +32,6 @@ static string key_type_to_str(int key_type) {
}
}
static bool char_is_unreserved_url(char c)
{
if (isalnum(c))
return true;
switch (c) {
case '-':
case '.':
case '_':
case '~':
return true;
default:
return false;
}
}
static bool validate_access_key(string& key)
{
const char *p = key.c_str();
while (*p) {
if (!char_is_unreserved_url(*p))
return false;
p++;
}
return true;
}
static void set_err_msg(std::string *sink, std::string msg)
{
if (sink && !msg.empty())
@ -502,41 +475,6 @@ int RGWAccessKeyPool::check_op(RGWUserAdminOpState& op_state,
return 0;
}
void rgw_generate_secret_key(CephContext* cct,
std::string& secret_key)
{
char secret_key_buf[SECRET_KEY_LEN + 1];
gen_rand_alphanumeric_plain(cct, secret_key_buf, sizeof(secret_key_buf));
secret_key = secret_key_buf;
}
int rgw_generate_access_key(const DoutPrefixProvider* dpp,
optional_yield y,
rgw::sal::Driver* driver,
std::string& access_key_id)
{
std::string id;
int r = 0;
do {
id.resize(PUBLIC_ID_LEN + 1);
gen_rand_alphanumeric_upper(dpp->get_cct(), id.data(), id.size());
id.pop_back(); // remove trailing null
if (!validate_access_key(id))
continue;
std::unique_ptr<rgw::sal::User> duplicate_check;
r = driver->get_user_by_access_key(dpp, id, y, &duplicate_check);
} while (r == 0);
if (r == -ENOENT) {
access_key_id = std::move(id);
return 0;
}
return r;
}
// Generate a new random key
int RGWAccessKeyPool::generate_key(const DoutPrefixProvider *dpp, RGWUserAdminOpState& op_state,
optional_yield y, std::string *err_msg)

File diff suppressed because it is too large Load Diff

View File

@ -1988,7 +1988,7 @@ static int commit_period(rgw::sal::ConfigStore* cfgstore,
RGWPeriod& period, string remote, const string& url,
std::optional<string> opt_region,
const string& access, const string& secret,
bool force)
bool force, rgw::SiteConfig* site)
{
auto& master_zone = period.get_master_zone().id;
if (master_zone.empty()) {
@ -2008,7 +2008,7 @@ static int commit_period(rgw::sal::ConfigStore* cfgstore,
// the master zone can commit locally
ret = rgw::commit_period(dpp(), null_yield, cfgstore, driver,
realm, realm_writer, current_period,
period, cerr, force);
period, cerr, force, *site);
if (ret < 0) {
cerr << "failed to commit period: " << cpp_strerror(-ret) << std::endl;
}
@ -2095,7 +2095,7 @@ static int update_period(rgw::sal::ConfigStore* cfgstore,
const string& remote, const string& url,
std::optional<string> opt_region,
const string& access, const string& secret,
Formatter *formatter, bool force)
Formatter *formatter, bool force, rgw::SiteConfig* site)
{
RGWRealm realm;
std::unique_ptr<rgw::sal::RealmWriter> realm_writer;
@ -2133,7 +2133,7 @@ static int update_period(rgw::sal::ConfigStore* cfgstore,
}
if (commit) {
ret = commit_period(cfgstore, realm, *realm_writer, period, remote, url,
opt_region, access, secret, force);
opt_region, access, secret, force, site);
if (ret < 0) {
cerr << "failed to commit period: " << cpp_strerror(-ret) << std::endl;
return ret;
@ -4890,7 +4890,7 @@ int main(int argc, const char **argv)
int ret = update_period(cfgstore.get(), realm_id, realm_name,
period_epoch, commit, remote, url,
opt_region, access_key, secret_key,
formatter.get(), yes_i_really_mean_it);
formatter.get(), yes_i_really_mean_it, site.get());
if (ret < 0) {
return -ret;
}
@ -7040,7 +7040,7 @@ int main(int argc, const char **argv)
int ret = update_period(cfgstore.get(), realm_id, realm_name,
period_epoch, commit, remote, url,
opt_region, access_key, secret_key,
formatter.get(), yes_i_really_mean_it);
formatter.get(), yes_i_really_mean_it, site.get());
if (ret < 0) {
return -ret;
}
@ -7069,7 +7069,7 @@ int main(int argc, const char **argv)
}
ret = commit_period(cfgstore.get(), realm, *realm_writer, period,
remote, url, opt_region, access_key, secret_key,
yes_i_really_mean_it);
yes_i_really_mean_it, site.get());
if (ret < 0) {
cerr << "failed to commit period: " << cpp_strerror(-ret) << std::endl;
return -ret;

View File

@ -521,28 +521,33 @@ int rgw::AppMain::init_frontends2(RGWLib* rgwlib)
/* ignore error */
}
// if we're part of a realm, add a watcher to respond to configuration changes
if (const auto& realm = env.site->get_realm(); realm) {
realm_watcher = env.cfgstore->create_realm_watcher(dpp, null_yield, *realm);
}
if (realm_watcher) {
pusher = std::make_unique<RGWPeriodPusher>(dpp, env.driver, env.cfgstore, null_yield);
realm_watcher->add_watcher(RGWRealmNotify::ZonesNeedPeriod, *pusher);
fe_pauser = std::make_unique<RGWFrontendPauser>(fes, pusher.get());
rgw_pauser = std::make_unique<RGWPauser>();
rgw_pauser->add_pauser(fe_pauser.get());
if (env.lua.background) {
rgw_pauser->add_pauser(env.lua.background);
#ifdef WITH_RADOSGW_RADOS
if (env.driver->get_name() == "rados") {
// add a watcher to respond to realm configuration changes
// if we're part of a realm, add a watcher to respond to configuration changes
if (const auto& realm = env.site->get_realm(); realm) {
realm_watcher = env.cfgstore->create_realm_watcher(dpp, null_yield, *realm);
}
if (realm_watcher) {
pusher = std::make_unique<RGWPeriodPusher>(dpp, env.driver, env.cfgstore, null_yield);
realm_watcher->add_watcher(RGWRealmNotify::ZonesNeedPeriod, *pusher);
fe_pauser = std::make_unique<RGWFrontendPauser>(fes, pusher.get());
rgw_pauser = std::make_unique<RGWPauser>();
rgw_pauser->add_pauser(fe_pauser.get());
if (env.lua.background) {
rgw_pauser->add_pauser(env.lua.background);
}
if (dedup_background) {
rgw_pauser->add_pauser(dedup_background.get());
}
need_context_pool();
reloader = std::make_unique<RGWRealmReloader>(
env, *implicit_tenant_context, service_map_meta, rgw_pauser.get(), *context_pool);
realm_watcher->add_watcher(RGWRealmNotify::Reload, *reloader);
need_context_pool();
reloader = std::make_unique<RGWRealmReloader>(
env, *implicit_tenant_context, service_map_meta, rgw_pauser.get(), *context_pool);
realm_watcher->add_watcher(RGWRealmNotify::Reload, *reloader);
}
}
#endif
return r;
} /* init_frontends2 */
@ -576,6 +581,7 @@ void rgw::AppMain::init_lua()
#endif
env.lua.manager = env.driver->get_lua_manager(install_dir);
#ifdef WITH_RADOSGW_RADOS
if (driver->get_name() == "rados") { /* Supported for only RadosStore */
lua_background = std::make_unique<
rgw::lua::Background>(driver, dpp->get_cct(), env.lua.manager.get());
@ -583,6 +589,7 @@ void rgw::AppMain::init_lua()
env.lua.background = lua_background.get();
static_cast<rgw::sal::RadosLuaManager*>(env.lua.manager.get())->watch_reload(dpp);
}
#endif
} /* init_lua */
void rgw::AppMain::init_dedup()
@ -608,7 +615,7 @@ void rgw::AppMain::shutdown(std::function<void(void)> finalize_async_signals)
realm_watcher.reset();
pusher.reset();
reloader.reset();
#ifdef WITH_RADOSGW_RADOS
if (env.driver->get_name() == "rados") {
if (g_conf().get_val<bool>("rgw_lua_enable"))
static_cast<rgw::sal::RadosLuaManager*>(env.lua.manager.get())->
@ -618,6 +625,7 @@ void rgw::AppMain::shutdown(std::function<void(void)> finalize_async_signals)
dedup_background->unwatch_reload(dpp);
}
}
#endif
for (auto& fe : fes) {
fe->stop();

View File

@ -18,6 +18,7 @@
#include "rgw_common.h"
#include "rgw_sync_policy.h"
#include "rgw_zone.h"
class RGWSI_Zone;
class RGWSI_SyncModules;

View File

@ -31,7 +31,7 @@
#include "rgw_formats.h"
#include "rgw_usage.h"
#include "rgw_object_expirer_core.h"
#include "driver/rados/rgw_zone.h"
#include "rgw_zone.h"
#include "rgw_sal_config.h"
#define dout_subsys ceph_subsys_rgw
@ -88,8 +88,7 @@ int main(const int argc, const char **argv)
ceph::async::io_context_pool context_pool{cct->_conf->rgw_thread_pool_size};
const DoutPrefix dp(cct.get(), dout_subsys, "rgw object expirer: ");
DriverManager::Config cfg;
cfg.store_name = "rados";
DriverManager::Config cfg = DriverManager::get_config(false, g_ceph_context);
cfg.filter_name = "none";
std::unique_ptr<rgw::sal::ConfigStore> cfgstore;
auto config_store_type = g_conf().get_val<std::string>("rgw_config_store");

View File

@ -13,6 +13,98 @@ std::string period_info_oid_prefix = "periods.";
#define FIRST_EPOCH 1
int RGWPeriod::get_zonegroup(RGWZoneGroup& zonegroup,
const string& zonegroup_id) const
{
map<string, RGWZoneGroup>::const_iterator iter;
if (!zonegroup_id.empty()) {
iter = period_map.zonegroups.find(zonegroup_id);
} else {
iter = period_map.zonegroups.find("default");
}
if (iter != period_map.zonegroups.end()) {
zonegroup = iter->second;
return 0;
}
return -ENOENT;
}
static int read_sync_status(const DoutPrefixProvider *dpp, rgw::sal::Driver* driver, rgw_meta_sync_status *sync_status)
{
int r = -ENOTSUP;
#ifdef WITH_RADOSGW_RADOS
rgw::sal::RadosStore* rados_store = static_cast<rgw::sal::RadosStore*>(driver);
// initialize a sync status manager to read the status
RGWMetaSyncStatusManager mgr(rados_store, rados_store->svc()->async_processor);
r = mgr.init(dpp);
if (r < 0) {
return r;
}
r = mgr.read_sync_status(dpp, sync_status);
mgr.stop();
#endif
return r;
}
int RGWPeriod::update_sync_status(const DoutPrefixProvider *dpp,
rgw::sal::Driver* driver, /* for now */
const RGWPeriod &current_period,
std::ostream& error_stream,
bool force_if_stale)
{
rgw_meta_sync_status status;
int r = read_sync_status(dpp, driver, &status);
if (r < 0) {
ldpp_dout(dpp, 0) << "period failed to read sync status: "
<< cpp_strerror(-r) << dendl;
return r;
}
std::vector<std::string> markers;
const auto current_epoch = current_period.get_realm_epoch();
if (current_epoch != status.sync_info.realm_epoch) {
// no sync status markers for the current period
ceph_assert(current_epoch > status.sync_info.realm_epoch);
const int behind = current_epoch - status.sync_info.realm_epoch;
if (!force_if_stale && current_epoch > 1) {
error_stream << "ERROR: This zone is " << behind << " period(s) behind "
"the current master zone in metadata sync. If this zone is promoted "
"to master, any metadata changes during that time are likely to "
"be lost.\n"
"Waiting for this zone to catch up on metadata sync (see "
"'radosgw-admin sync status') is recommended.\n"
"To promote this zone to master anyway, add the flag "
"--yes-i-really-mean-it." << std::endl;
return -EINVAL;
}
// empty sync status markers - other zones will skip this period during
// incremental metadata sync
markers.resize(status.sync_info.num_shards);
} else {
markers.reserve(status.sync_info.num_shards);
for (auto& i : status.sync_markers) {
auto& marker = i.second;
// filter out markers from other periods
if (marker.realm_epoch != current_epoch) {
marker.marker.clear();
}
markers.emplace_back(std::move(marker.marker));
}
}
std::swap(sync_status, markers);
return 0;
}
void RGWPeriod::generate_test_instances(list<RGWPeriod*> &o)
{
RGWPeriod *z = new RGWPeriod;
o.push_back(z);
o.push_back(new RGWPeriod);
}
const string& RGWPeriod::get_info_oid_prefix() const
{
return period_info_oid_prefix;

View File

@ -118,8 +118,7 @@ void RGWRealmReloader::reload()
ldpp_dout(&dp, 1) << "Creating new driver" << dendl;
// recreate and initialize a new driver
DriverManager::Config cfg;
cfg.store_name = "rados";
DriverManager::Config cfg = DriverManager::get_config(false, g_ceph_context);
cfg.filter_name = "none";
env.driver = DriverManager::get_storage(&dp, cct, cfg, io_context,
*env.site,

View File

@ -13,7 +13,7 @@
#include "rgw_rest_iam_group.h"
#include "rgw_rest_iam_user.h"
#include "rgw_rest_conn.h"
#include "driver/rados/rgw_zone.h"
#include "rgw_zone.h"
#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_rgw

View File

@ -48,7 +48,9 @@
//#define dout_context g_ceph_context
extern "C" {
#ifdef WITH_RADOSGW_RADOS
extern rgw::sal::Driver* newRadosStore(boost::asio::io_context* io_context);
#endif
#ifdef WITH_RADOSGW_DBSTORE
extern rgw::sal::Driver* newDBStore(CephContext *cct);
#endif
@ -86,6 +88,7 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
rgw::sal::Driver* driver{nullptr};
if (cfg.store_name.compare("rados") == 0) {
#ifdef WITH_RADOSGW_RADOS
driver = newRadosStore(&io_context);
RGWRados* rados = static_cast<rgw::sal::RadosStore* >(driver)->getRados();
@ -110,7 +113,9 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
delete driver;
return nullptr;
}
#endif
}
#ifdef WITH_RADOSGW_RADOS
else if (cfg.store_name.compare("d3n") == 0) {
driver = new rgw::sal::RadosStore(io_context);
RGWRados* rados = new D3nRGWDataCache<RGWRados>;
@ -151,6 +156,7 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
lsubdout(cct, rgw, 1) << "rgw_d3n: rgw_d3n_l1_eviction_policy=" <<
cct->_conf->rgw_d3n_l1_eviction_policy << dendl;
}
#endif
#ifdef WITH_RADOSGW_DBSTORE
else if (cfg.store_name.compare("dbstore") == 0) {
driver = newDBStore(cct);
@ -238,6 +244,7 @@ rgw::sal::Driver* DriverManager::init_raw_storage_provider(const DoutPrefixProvi
{
rgw::sal::Driver* driver = nullptr;
if (cfg.store_name.compare("rados") == 0) {
#ifdef WITH_RADOSGW_RADOS
driver = newRadosStore(&io_context);
RGWRados* rados = static_cast<rgw::sal::RadosStore* >(driver)->getRados();
@ -259,6 +266,7 @@ rgw::sal::Driver* DriverManager::init_raw_storage_provider(const DoutPrefixProvi
delete driver;
return nullptr;
}
#endif
} else if (cfg.store_name.compare("dbstore") == 0) {
#ifdef WITH_RADOSGW_DBSTORE
driver = newDBStore(cct);
@ -320,6 +328,7 @@ DriverManager::Config DriverManager::get_config(bool admin, CephContext* cct)
// Get the store backend
const auto& config_store = g_conf().get_val<std::string>("rgw_backend_store");
if (config_store == "rados") {
#ifdef WITH_RADOSGW_RADOS
cfg.store_name = "rados";
/* Check to see if d3n is configured, but only for non-admin */
@ -334,6 +343,7 @@ DriverManager::Config DriverManager::get_config(bool admin, CephContext* cct)
cfg.store_name = "d3n";
}
}
#endif
}
#ifdef WITH_RADOSGW_DBSTORE
else if (config_store == "dbstore") {
@ -373,14 +383,18 @@ auto DriverManager::create_config_store(const DoutPrefixProvider* dpp,
-> std::unique_ptr<rgw::sal::ConfigStore>
{
try {
#ifdef WITH_RADOSGW_RADOS
if (type == "rados") {
return rgw::rados::create_config_store(dpp);
}
#endif
#ifdef WITH_RADOSGW_DBSTORE
} else if (type == "dbstore") {
if (type == "dbstore") {
const auto uri = g_conf().get_val<std::string>("dbstore_config_uri");
return rgw::dbstore::create_config_store(dpp, uri);
}
#endif
} else if (type == "json") {
if (type == "json") {
auto filename = g_conf().get_val<std::string>("rgw_json_config");
return rgw::sal::create_json_config_store(dpp, filename);
} else {

View File

@ -110,3 +110,65 @@ void rgw_get_anon_user(RGWUserInfo& info)
info.access_keys.clear();
}
static bool char_is_unreserved_url(char c)
{
if (isalnum(c))
return true;
switch (c) {
case '-':
case '.':
case '_':
case '~':
return true;
default:
return false;
}
}
static bool validate_access_key(string& key)
{
const char *p = key.c_str();
while (*p) {
if (!char_is_unreserved_url(*p))
return false;
p++;
}
return true;
}
int rgw_generate_access_key(const DoutPrefixProvider* dpp,
optional_yield y,
rgw::sal::Driver* driver,
std::string& access_key_id)
{
std::string id;
int r = 0;
do {
id.resize(PUBLIC_ID_LEN + 1);
gen_rand_alphanumeric_upper(dpp->get_cct(), id.data(), id.size());
id.pop_back(); // remove trailing null
if (!validate_access_key(id))
continue;
std::unique_ptr<rgw::sal::User> duplicate_check;
r = driver->get_user_by_access_key(dpp, id, y, &duplicate_check);
} while (r == 0);
if (r == -ENOENT) {
access_key_id = std::move(id);
return 0;
}
return r;
}
void rgw_generate_secret_key(CephContext* cct,
std::string& secret_key)
{
char secret_key_buf[SECRET_KEY_LEN + 1];
gen_rand_alphanumeric_plain(cct, secret_key_buf, sizeof(secret_key_buf));
secret_key = secret_key_buf;
}

File diff suppressed because it is too large Load Diff

View File

@ -439,6 +439,7 @@ WRITE_CLASS_ENCODER(RGWPeriodConfig)
class RGWRealm;
class RGWPeriod;
namespace rgw {class SiteConfig;}
class RGWRealm
{
@ -752,7 +753,7 @@ int commit_period(const DoutPrefixProvider* dpp, optional_yield y,
RGWRealm& realm, sal::RealmWriter& realm_writer,
const RGWPeriod& current_period,
RGWPeriod& info, std::ostream& error_stream,
bool force_if_stale);
bool force_if_stale, const rgw::SiteConfig& site);
/// Look up a zonegroup by its id. If no id is given, look it up by name.

View File

@ -12,7 +12,7 @@
#include "rgw_coroutine.h"
#include "rgw_cr_rados.h"
#include "driver/rados/rgw_zone.h" // FIXME: subclass dependency
#include "rgw/rgw_zone.h"
#include "common/errno.h"

View File

@ -427,11 +427,6 @@ const RGWZone& RGWSI_Zone::get_zone() const
return *zone_public_config;
}
const RGWZoneGroup& RGWSI_Zone::get_zonegroup() const
{
return *zonegroup;
}
int RGWSI_Zone::get_zonegroup(const string& id, RGWZoneGroup& zg) const
{
int ret = 0;
@ -516,11 +511,6 @@ bool RGWSI_Zone::need_to_sync() const
current_period->get_id().empty());
}
bool RGWSI_Zone::need_to_log_data() const
{
return (zone_public_config->log_data && sync_module_exports_data());
}
bool RGWSI_Zone::is_meta_master() const
{
if (!zonegroup->is_master_zonegroup()) {

View File

@ -75,7 +75,7 @@ public:
const RGWZoneParams& get_zone_params() const;
const RGWPeriod& get_current_period() const;
const RGWRealm& get_realm() const;
const RGWZoneGroup& get_zonegroup() const;
const RGWZoneGroup& get_zonegroup() const { return *zonegroup; };
int get_zonegroup(const std::string& id, RGWZoneGroup& zonegroup) const;
const RGWZone& get_zone() const;
@ -134,7 +134,7 @@ public:
bool is_meta_master() const;
bool need_to_sync() const;
bool need_to_log_data() const;
bool need_to_log_data() const { return (zone_public_config->log_data && sync_module_exports_data()); };
bool need_to_log_metadata() const;
bool can_reshard() const;
bool is_syncing_bucket_meta() const;

View File

@ -614,7 +614,7 @@ if(WITH_RBD)
add_dependencies(tests unittest_librbd rbd-mirror)
endif(WITH_RBD_MIRROR)
endif(WITH_RBD)
if(WITH_RADOSGW)
if(WITH_RADOSGW AND WITH_RADOSGW_RADOS)
add_dependencies(tests radosgw radosgw-admin)
endif()
#add dependency from fio just to ensure the plugin build isn't failing

View File

@ -143,6 +143,7 @@ add_executable(unittest_rgw_ratelimit test_rgw_ratelimit.cc $<TARGET_OBJECTS:uni
target_link_libraries(unittest_rgw_ratelimit ${rgw_libs})
add_ceph_unittest(unittest_rgw_ratelimit)
if(WITH_RADOSGW_RADOS)
# ceph_test_rgw_manifest
set(test_rgw_manifest_srcs test_rgw_manifest.cc)
add_executable(ceph_test_rgw_manifest
@ -165,8 +166,10 @@ target_link_libraries(ceph_test_rgw_manifest
${CMAKE_DL_LIBS}
${UNITTEST_LIBS}
${CRYPTO_LIBS})
endif()
set(test_rgw_obj_srcs test_rgw_obj.cc)
if(WITH_RADOSGW_RADOS)
add_executable(ceph_test_rgw_obj
${test_rgw_obj_srcs}
)
@ -188,6 +191,7 @@ target_link_libraries(ceph_test_rgw_obj
${CRYPTO_LIBS}
)
install(TARGETS ceph_test_rgw_obj DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
set(test_rgw_crypto_srcs test_rgw_crypto.cc)
add_executable(unittest_rgw_crypto
@ -312,11 +316,13 @@ target_include_directories(unittest_rgw_url
SYSTEM PRIVATE "${CMAKE_SOURCE_DIR}/src/rgw")
target_link_libraries(unittest_rgw_url ${rgw_libs})
if(WITH_RADOSGW_RADOS)
add_executable(ceph_test_rgw_gc_log test_rgw_gc_log.cc $<TARGET_OBJECTS:unit-main>)
target_include_directories(ceph_test_rgw_gc_log
SYSTEM PRIVATE "${CMAKE_SOURCE_DIR}/src/rgw")
target_link_libraries(ceph_test_rgw_gc_log ${rgw_libs} radostest-cxx)
install(TARGETS ceph_test_rgw_gc_log DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
add_executable(unittest_rgw_shard_io test_rgw_shard_io.cc)
add_ceph_unittest(unittest_rgw_shard_io)
@ -325,6 +331,7 @@ target_link_libraries(unittest_rgw_shard_io ${rgw_libs} unit-main ${UNITTEST_LIB
add_ceph_test(test-ceph-diff-sorted.sh
${CMAKE_CURRENT_SOURCE_DIR}/test-ceph-diff-sorted.sh)
if(WITH_RADOSGW_RADOS)
# unittest_log_backing
add_executable(unittest_log_backing test_log_backing.cc)
target_include_directories(unittest_log_backing
@ -335,6 +342,7 @@ target_link_libraries(unittest_log_backing
neoradostest-support
${UNITTEST_LIBS}
${rgw_libs})
endif()
add_executable(unittest_rgw_lua test_rgw_lua.cc)
add_ceph_unittest(unittest_rgw_lua)
@ -342,6 +350,7 @@ target_include_directories(unittest_rgw_lua
SYSTEM PRIVATE "${CMAKE_SOURCE_DIR}/src/rgw")
target_link_libraries(unittest_rgw_lua unit-main ${rgw_libs})
if(WITH_RADOSGW_RADOS)
add_executable(radosgw-cr-test rgw_cr_test.cc)
target_link_libraries(radosgw-cr-test ${rgw_libs} librados
cls_rgw_client cls_otp_client cls_lock_client cls_refcount_client
@ -351,6 +360,7 @@ target_link_libraries(radosgw-cr-test ${rgw_libs} librados
OATH::OATH
${CURL_LIBRARIES} ${EXPAT_LIBRARIES} ${BLKID_LIBRARIES}
GTest::GTest)
endif()
if(WITH_RADOSGW_POSIX)
# unittest_posix_bucket_cache
@ -376,6 +386,7 @@ target_link_libraries(unittest_rgw_posix_driver ${UNITTEST_LIBS}
${rgw_libs} ${LMDB_LIBRARIES})
endif(WITH_RADOSGW_POSIX)
if(WITH_RADOSGW_RADOS)
# ceph_test_datalog
add_executable(ceph_test_datalog test_datalog.cc)
target_include_directories(ceph_test_datalog
@ -387,6 +398,7 @@ target_link_libraries(ceph_test_datalog
${UNITTEST_LIBS}
${rgw_libs})
install(TARGETS ceph_test_datalog DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if(WITH_CATCH2)
add_executable(unittest_rgw_hex

View File

@ -21,7 +21,7 @@
#include "rgw_cr_rados.h"
#include "rgw_sal.h"
#include "rgw_sal_rados.h"
#include "driver/rados/rgw_zone.h"
#include "rgw/rgw_zone.h"
#include "rgw_sal_config.h"
#include "gtest/gtest.h"

View File

@ -32,7 +32,7 @@
#include "rgw_op.h"
#include "rgw_process_env.h"
#include "rgw_sal_rados.h"
#include "driver/rados/rgw_zone.h"
#include "rgw_zone.h"
#include "rgw_sal_config.h"
using std::string;