mirror of
https://github.com/ceph/ceph
synced 2024-12-17 17:05:42 +00:00
rgw: replace logic that compares regions
The logic was a bit broken. Basically, we want to make sure that region names are the same. However, if region name is not set then we need to check whether it's the master region. This can happen in upgrade cases where originally we didn't have a region name set. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
parent
e4d2787b02
commit
4e05786a58
@ -334,8 +334,7 @@ static int rgw_build_policies(RGWRados *store, struct req_state *s, bool only_bu
|
||||
ret = store->get_bucket_info(s->obj_ctx, copy_source_str, source_info, NULL);
|
||||
if (ret == 0) {
|
||||
string& region = source_info.region;
|
||||
s->local_source = (region.empty() && store->region.is_master) ||
|
||||
(region == store->region.name);
|
||||
s->local_source = store->region.equals(region);
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,8 +361,7 @@ static int rgw_build_policies(RGWRados *store, struct req_state *s, bool only_bu
|
||||
s->bucket_owner = s->bucket_acl->get_owner();
|
||||
|
||||
string& region = s->bucket_info.region;
|
||||
if (s->bucket_exists && ((region.empty() && !store->region.is_master) ||
|
||||
(region != store->region.name))) {
|
||||
if (s->bucket_exists && !store->region.equals(region)) {
|
||||
ldout(s->cct, 0) << "NOTICE: request for data in a different region (" << region << " != " << store->region.name << ")" << dendl;
|
||||
/* we now need to make sure that the operation actually requires copy source, that is
|
||||
* it's a copy operation
|
||||
|
@ -259,6 +259,13 @@ int RGWRegion::store_info(bool exclusive)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int RGWRegion::equals(const string& other_region)
|
||||
{
|
||||
if (is_master && other_region.empty())
|
||||
return true;
|
||||
|
||||
return (name == other_region);
|
||||
}
|
||||
|
||||
void RGWZoneParams::init_default(RGWRados *store)
|
||||
{
|
||||
@ -429,8 +436,7 @@ int RGWRegionMap::update(RGWRegion& region)
|
||||
{
|
||||
Mutex::Locker l(lock);
|
||||
|
||||
if (region.is_master && !master_region.empty() &&
|
||||
master_region.compare(region.name) != 0) {
|
||||
if (region.is_master && !region.equals(master_region)) {
|
||||
derr << "cannot update region map, master_region conflict" << dendl;
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -1938,8 +1944,7 @@ int RGWRados::set_bucket_location_by_rule(const string& location_rule, const std
|
||||
map<string, RGWZonePlacementInfo>::iterator piter = zone.placement_pools.find(location_rule);
|
||||
if (piter == zone.placement_pools.end()) {
|
||||
/* couldn't find, means we cannot really place data for this bucket in this zone */
|
||||
if ((region_name.empty() && region.is_master) ||
|
||||
region_name == region.name) {
|
||||
if (region.equals(region_name)) {
|
||||
/* that's a configuration error, zone should have that rule, as we're within the requested
|
||||
* region */
|
||||
return -EINVAL;
|
||||
@ -2486,11 +2491,8 @@ int RGWRados::copy_obj(void *ctx,
|
||||
append_rand_alpha(cct, dest_obj.object, shadow_oid, 32);
|
||||
shadow_obj.init_ns(dest_obj.bucket, shadow_oid, shadow_ns);
|
||||
|
||||
remote_dest = ((dest_bucket_info.region.empty() && !region.is_master) ||
|
||||
(dest_bucket_info.region != region.name));
|
||||
|
||||
remote_src = ((src_bucket_info.region.empty() && !region.is_master) ||
|
||||
(src_bucket_info.region != region.name));
|
||||
remote_dest = !region.equals(dest_bucket_info.region);
|
||||
remote_src = !region.equals(src_bucket_info.region);
|
||||
|
||||
if (remote_src && remote_dest) {
|
||||
ldout(cct, 0) << "ERROR: can't copy object when both src and dest buckets are remote" << dendl;
|
||||
|
@ -619,6 +619,7 @@ struct RGWRegion {
|
||||
int read_info(const string& region_name);
|
||||
int read_default(RGWDefaultRegionInfo& default_region);
|
||||
int set_as_default();
|
||||
int equals(const string& other_region);
|
||||
|
||||
static string get_pool_name(CephContext *cct);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user