From: Orit Wasserman Date: Tue, 3 Nov 2015 15:21:32 +0000 (+0100) Subject: rgw: fix bucket creation and deletion when there is no realm or period configured X-Git-Tag: v10.1.0~354^2~248 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0c0c9960753594cc825dbdfcf115bf5adcde00f3;p=ceph.git rgw: fix bucket creation and deletion when there is no realm or period configured Signed-off-by: Orit Wasserman --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 53f21d06e3aaf..81d646bd9b6e3 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -409,13 +409,13 @@ static int rgw_build_bucket_policies(RGWRados *store, struct req_state *s) s->bucket_owner = s->bucket_acl->get_owner(); RGWZoneGroup zonegroup; - ret = store->current_period.get_zonegroup(zonegroup, s->bucket_info.zonegroup); + ret = store->get_zonegroup(s->bucket_info.zonegroup, zonegroup); if (!ret && !zonegroup.endpoints.empty()) { s->zonegroup_endpoint = zonegroup.endpoints.front(); } if (s->bucket_exists && !store->get_zonegroup().equals(s->bucket_info.zonegroup)) { - ldout(s->cct, 0) << "NOTICE: request for data in a different zonegroup (" << s->bucket_info.zonegroup << " != " << store->get_zonegroup().get_name() << ")" << dendl; + ldout(s->cct, 0) << "NOTICE: request for data in a different zonegroup (" << s->bucket_info.zonegroup << " != " << store->get_zonegroup().get_id() << ")" << dendl; /* we now need to make sure that the operation actually requires copy source, that is * it's a copy operation */ diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index b170e1038b28c..067561b3e1939 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -137,6 +137,7 @@ const string& RGWZoneGroup::get_pool_name(CephContext *cct_) int RGWZoneGroup::create_default(bool old_format) { name = default_zonegroup_name; + is_master = true; RGWZoneGroupPlacementTarget placement_target; placement_target.name = "default-placement"; @@ -1242,6 +1243,7 @@ int RGWZoneParams::create_default(bool old_format) name = id; } + r = set_as_default(); return r; } @@ -3289,13 +3291,14 @@ int RGWRados::init_complete() return ret; } } + ldout(cct, 20) << "zonegroup " << zonegroup.get_name() << dendl; if (zonegroup.is_master) { rest_master_conn = new RGWRESTConn(cct, this, zonegroup.endpoints); } } if (!has_period_zone) { - ldout(cct, 10) << " cannot find current period zonegroup using local zonegroup" << dendl; + ldout(cct, 10) << "Cannot find current period zone using local zone" << dendl; if (creating_defaults && cct->_conf->rgw_zone.empty()) { zone_params.set_name(default_zone_name); } @@ -3307,6 +3310,7 @@ int RGWRados::init_complete() map::iterator zone_iter = zonegroup.zones.find(zone_params.get_id()); if (zone_iter != zonegroup.zones.end()) { zone_public_config = zone_iter->second; + ldout(cct, 20) << "zone " << zone_params.get_name() << dendl; } else { lderr(cct) << "Cannot find zone " << zone_params.get_name() << dendl; return -EINVAL; @@ -4728,17 +4732,15 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket, return -ENOENT; } -int RGWRados::select_new_bucket_location(RGWUserInfo& user_info, const string& zonegroup_name, const string& request_rule, +int RGWRados::select_new_bucket_location(RGWUserInfo& user_info, const string& zonegroup_id, const string& request_rule, const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, string *pselected_rule) { /* first check that rule exists within the specific zonegroup */ RGWZoneGroup zonegroup; - if (!current_period.get_id().empty()) { - int ret = current_period.get_zonegroup(zonegroup, zonegroup_name); - if (ret < 0) { - ldout(cct, 0) << "could not find zonegroup " << zonegroup_name << " in zonegroup map" << dendl; - return ret; - } + int ret = get_zonegroup(zonegroup_id, zonegroup); + if (ret < 0) { + ldout(cct, 0) << "could not find zonegroup " << zonegroup_id << " in current period" << dendl; + return ret; } /* now check that tag exists within zonegroup */ diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index b00f2d1d2cd69..b719bd7c4face 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1774,6 +1774,8 @@ protected: RGWZone period_zone; /* external zone params, e.g., entrypoints, log flags, etc. */ bool has_period_zonegroup; bool has_period_zone; + + RGWPeriod current_period; public: RGWRados() : max_req_id(0), lock("rados_timer_lock"), watchers_lock("watchers_lock"), timer(NULL), gc(NULL), obj_expirer(NULL), use_gc_thread(false), quota_threads(false), @@ -1820,11 +1822,21 @@ public: string host_id; RGWRealm realm; - RGWPeriod current_period; + RGWRESTConn *rest_master_conn; map zone_conn_map; map zonegroup_conn_map; + int get_zonegroup(const string& id, RGWZoneGroup& zonegroup) { + int ret = 0; + if (id == get_zonegroup().get_id()) { + zonegroup = get_zonegroup(); + } else if (!current_period.get_id().empty()) { + ret = current_period.get_zonegroup(zonegroup, zonegroup_id); + } + return ret; + } + RGWZoneParams& get_zone_params() { return zone_params; } RGWZoneGroup& get_zonegroup() { if (has_period_zonegroup) {