]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: bucket link: master rebase adaptions.
authorMarcus Watts <mwatts@redhat.com>
Fri, 7 Dec 2018 09:42:37 +0000 (04:42 -0500)
committerShilpa Jagannath <smanjara@redhat.com>
Tue, 30 Jul 2019 08:30:45 +0000 (14:00 +0530)
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 <mwatts@redhat.com>
src/rgw/rgw_auth_registry.h
src/rgw/rgw_bucket.cc
src/rgw/rgw_rest_sts.h

index f03c1d34cca03c80ae988bd454f44c26d2ce62c2..2da79a1669fc612ae84dd48ebbe9cde800fbe6e9 100644 (file)
@@ -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 {
index 9a054f38edb51d56b96f044ca3a25cdb128e26f6..2a19b1b39dc511f5ab997ee2c51d4c92362ceda8 100644 (file)
@@ -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<string, bufferlist>::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<string, bufferlist> 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,
index d9baa2c3cacd8a93660442aba6625178da1a89af..822f3679e50d88876dd73d6527a152732cc5ec31 100644 (file)
@@ -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<rgw::auth::TokenExtractor*>(this),
                         static_cast<rgw::auth::WebIdentityApplier::Factory*>(this)) {