]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: forward RGWPutBucketPolicy to meta master
authorCasey Bodley <cbodley@redhat.com>
Fri, 16 Jun 2017 17:57:06 +0000 (13:57 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 16 Jun 2017 18:44:44 +0000 (14:44 -0400)
Fixes: http://tracker.ceph.com/issues/20297
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_op.cc

index 9f28b313c3a98b5ede3256b63b358120d1c23183..4a0fe93bc4b195b0ea1d61f438198f297fd1d402 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "common/Clock.h"
 #include "common/armor.h"
+#include "common/errno.h"
 #include "common/mime.h"
 #include "common/utf8.h"
 #include "common/ceph_json.h"
@@ -6468,9 +6469,18 @@ void RGWPutBucketPolicy::execute()
     return;
   }
 
+  bufferlist in_data = bufferlist::static_from_mem(data, len);
+
+  if (!store->is_meta_master()) {
+    op_ret = forward_request_to_master(s, NULL, store, in_data, nullptr);
+    if (op_ret < 0) {
+      ldout(s->cct, 20) << "forward_request_to_master returned ret=" << op_ret << dendl;
+      return;
+    }
+  }
+
   try {
-    Policy p(s->cct, s->bucket_tenant,
-            bufferlist::static_from_mem(data, len));
+    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);
@@ -6480,6 +6490,7 @@ void RGWPutBucketPolicy::execute()
       op_ret = 0; /* lost a race, but it's ok because policies are immutable */
     }
   } catch (rgw::IAM::PolicyParseException& e) {
+    ldout(s->cct, 20) << "failed to parse policy: " << e.what() << dendl;
     op_ret = -EINVAL;
   }
 }