]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Handle stale bucket info in RGWPutBucketPolicy
authorAdam C. Emerson <aemerson@redhat.com>
Fri, 17 Nov 2017 21:15:04 +0000 (16:15 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 27 Nov 2017 20:57:15 +0000 (15:57 -0500)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/rgw/rgw_op.cc

index 770c6609e648f93292ed2b2cc2f2f8153c28aab7..aa62e40f24a45fd7b205dabd810d58cac52167b0 100644 (file)
@@ -6879,15 +6879,15 @@ void RGWPutBucketPolicy::execute()
   }
 
   try {
-    Policy p(s->cct, s->bucket_tenant, in_data);
-    auto attrs = s->bucket_attrs;
-    attrs[RGW_ATTR_IAM_POLICY].clear();
-    attrs[RGW_ATTR_IAM_POLICY].append(p.text);
-    op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs,
-                                 &s->bucket_info.objv_tracker);
-    if (op_ret == -ECANCELED) {
-      op_ret = 0; /* lost a race, but it's ok because policies are immutable */
-    }
+    const Policy p(s->cct, s->bucket_tenant, in_data);
+    op_ret = retry_raced_bucket_write(store, s, [&p, this] {
+       auto attrs = s->bucket_attrs;
+       attrs[RGW_ATTR_IAM_POLICY].clear();
+       attrs[RGW_ATTR_IAM_POLICY].append(p.text);
+       op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs,
+                                     &s->bucket_info.objv_tracker);
+       return op_ret;
+      });
   } catch (rgw::IAM::PolicyParseException& e) {
     ldout(s->cct, 20) << "failed to parse policy: " << e.what() << dendl;
     op_ret = -EINVAL;