From: Marcus Watts Date: Fri, 7 Dec 2018 09:42:37 +0000 (-0500) Subject: rgw: bucket link: master rebase adaptions. X-Git-Tag: v15.1.0~1944^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2f25d4dc747fe5114fd41148e3a73f644a5dfc98;p=ceph.git rgw: bucket link: master rebase adaptions. The previous few commits for rgw_bucket.cc could originally be applied one at a time resulting in a complete buildable copy of ceph at each step. Recent independent changes to rgw_bucket.cc have affected the same logic, so the original commits no longer build. This commit resyncs things with master such that the result will build. I'm preserving the intermediate commits for now, since that's what was originally backported to jewel, If this causes problems, these commits should be squashed together; except for backport purposes the intermediate versions have no other value. One other change here: omit logic that copied "VERSION_ATTR" to the new container object. This should already be provided for elsewhere. Fixes: http://tracker.ceph.com/issues/35885 Signed-off-by: Marcus Watts --- diff --git a/src/rgw/rgw_auth_registry.h b/src/rgw/rgw_auth_registry.h index f03c1d34cca..2da79a1669f 100644 --- a/src/rgw/rgw_auth_registry.h +++ b/src/rgw/rgw_auth_registry.h @@ -64,7 +64,8 @@ public: RGWRados* const store) : s3_main_strategy(cct, implicit_tenant_context, store), s3_post_strategy(cct, implicit_tenant_context, store), - swift_strategy(cct, implicit_tenant_context, store) { + swift_strategy(cct, implicit_tenant_context, store), + sts_strategy(cct, implicit_tenant_context, store) { } const s3_main_strategy_t& get_s3_main() const { diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 9a054f38edb..2a19b1b39dc 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -382,7 +382,7 @@ int rgw_bucket_parse_bucket_key(CephContext *cct, const string& key, // split tenant/name auto pos = name.find('/'); - if (pos != boost::string_ref::npos) { + if (pos != string::npos) { auto tenant = name.substr(0, pos); bucket->tenant.assign(tenant.begin(), tenant.end()); name = name.substr(pos + 1); @@ -390,7 +390,7 @@ int rgw_bucket_parse_bucket_key(CephContext *cct, const string& key, // split name:instance pos = name.find(':'); - if (pos != boost::string_ref::npos) { + if (pos != string::npos) { instance = name.substr(pos + 1); name = name.substr(0, pos); } @@ -398,7 +398,7 @@ int rgw_bucket_parse_bucket_key(CephContext *cct, const string& key, // split instance:shard pos = instance.find(':'); - if (pos == boost::string_ref::npos) { + if (pos == string::npos) { bucket->bucket_id.assign(instance.begin(), instance.end()); *shard_id = -1; return 0; @@ -817,7 +817,7 @@ int RGWBucket::init(RGWRados *storage, RGWBucketAdminOpState& op_state, // split possible tenant/name auto pos = bucket_name.find('/'); - if (pos != boost::string_ref::npos) { + if (pos != string::npos) { bucket_tenant = bucket_name.substr(0, pos); bucket_name = bucket_name.substr(pos + 1); } @@ -870,7 +870,7 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, bucket.tenant = tenant; if (!op_state.new_bucket_name.empty()) { auto pos = op_state.new_bucket_name.find('/'); - if (pos != boost::string_ref::npos) { + if (pos != string::npos) { bucket.tenant = op_state.new_bucket_name.substr(0, pos); bucket.name = op_state.new_bucket_name.substr(pos + 1); } else { @@ -883,9 +883,12 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, map::iterator aiter = attrs.find(RGW_ATTR_ACL); if (aiter == attrs.end()) { - // XXX why isn't this an error? mdw 20180825 - ldout(store->ctx(), 0) << "WARNING: bucket link will do nothing because no acl on bucket=" << old_bucket.name << dendl; - return 0; + // should never happen; only pre-argonaut buckets lacked this. + ldout(store->ctx(), 0) << "WARNING: can't bucket link because no acl on bucket=" << old_bucket.name << dendl; + set_err_msg(err_msg, + "While crossing the Anavros you have displeased the goddess Hera." + " You must sacrifice your ancient bucket " + bucket.bucket_id); + return -EINVAL; } bufferlist aclbl = aiter->second; RGWAccessControlPolicy policy; @@ -925,9 +928,16 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, return r; } + const rgw_pool& root_pool = store->svc.zone->get_zone_params().domain_root; + std::string bucket_entry; + rgw_make_bucket_entry_name(tenant, bucket_name, bucket_entry); + rgw_raw_obj obj(root_pool, bucket_entry); + auto obj_ctx = store->svc.sysobj->init_obj_ctx(); + auto sysobj = obj_ctx.get_obj(obj); rgw_raw_obj obj_bucket_instance; + store->get_bucket_instance_obj(bucket, obj_bucket_instance); - auto sysobj = obj_ctx.get_obj(obj); + auto inst_sysobj = obj_ctx.get_obj(obj_bucket_instance); r = sysobj.wop() .set_objv_tracker(&objv_tracker) .write_attr(RGW_ATTR_ACL, aclbl, null_yield); @@ -953,12 +963,6 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, ep.creation_time = bucket_info.creation_time; ep.linked = true; map ep_attrs; - // XXX I am not convinced this is at all necessary; but previous - // versions would have found and copied VERSION_ATTR so I will - // do likewise for now... mdw 20180825 - auto version_iter = attrs.find(VERSION_ATTR); - if (version_iter != attrs.end()) - ep_attrs[VERSION_ATTR] = version_iter->second; rgw_ep_info ep_data{ep, ep_attrs}; r = rgw_link_bucket(store, user_info.user_id, bucket_info.bucket, diff --git a/src/rgw/rgw_rest_sts.h b/src/rgw/rgw_rest_sts.h index d9baa2c3cac..822f3679e50 100644 --- a/src/rgw/rgw_rest_sts.h +++ b/src/rgw/rgw_rest_sts.h @@ -53,6 +53,7 @@ class DefaultStrategy : public rgw::auth::Strategy, public rgw::auth::TokenExtractor, public rgw::auth::WebIdentityApplier::Factory { RGWRados* const store; + ImplicitTenants& implicit_tenant_context; /* The engine. */ const WebTokenEngine web_token_engine; @@ -74,8 +75,10 @@ class DefaultStrategy : public rgw::auth::Strategy, public: DefaultStrategy(CephContext* const cct, + ImplicitTenants& implicit_tenant_context, RGWRados* const store) : store(store), + implicit_tenant_context(implicit_tenant_context), web_token_engine(cct, static_cast(this), static_cast(this)) {