]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw-multisite: fix the problem of rgw website configure request not redirect to metad... 15082/head
authoryuliyang <yuliyang@cmss.chinamobile.com>
Mon, 15 May 2017 08:49:13 +0000 (16:49 +0800)
committeryuliyang <yuliyang@cmss.chinamobile.com>
Wed, 14 Jun 2017 23:19:35 +0000 (07:19 +0800)
Signed-off-by: yuliyang <yuliyang@cmss.chinamobile.com>
src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_rest_s3.cc
src/test/rgw/rgw_multi/tests.py

index 29adbc58aa48e7841bf9acc7328273a0f0fef0fb..57e3235c3b1b66acb98332c9fdfa8a3f9fd2d826 100644 (file)
@@ -1969,6 +1969,14 @@ void RGWSetBucketWebsite::execute()
   if (op_ret < 0)
     return;
 
+  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) << __func__ << " forward_request_to_master returned ret=" << op_ret << dendl;
+      return;
+    }
+  }
+
   s->bucket_info.has_website = true;
   s->bucket_info.website_conf = website_conf;
 
index 3589fb489855b32aee649170644283669ac6a54a..2d8dc4edd352bc630d205a0508d497919ed57281 100644 (file)
@@ -748,6 +748,7 @@ public:
 
 class RGWSetBucketWebsite : public RGWOp {
 protected:
+  bufferlist in_data;
   RGWBucketWebsiteConf website_conf;
 public:
   RGWSetBucketWebsite() {}
index 0b2550d704b2e0c0c8806af03b93c0ef6d395e89..684e65a66cee4aa0a8f9ff6054e5ee1d2c0133ab 100644 (file)
@@ -850,6 +850,9 @@ int RGWSetBucketWebsite_ObjStore_S3::get_params()
       }
   }
 
+  bufferptr in_ptr(data, len);
+  in_data.append(in_ptr);
+
   RGWXMLDecoder::XMLParser parser;
   if (!parser.init()) {
     ldout(s->cct, 0) << "ERROR: failed to initialize parser" << dendl;
index fff682d37e49216768e7660a6ecc5132a857bc2e..58426dfbfe1b8083bc98660a76e4873fd8d0bf37 100644 (file)
@@ -13,6 +13,7 @@ from itertools import combinations
 
 import boto
 import boto.s3.connection
+from boto.s3.website import WebsiteConfiguration
 
 from nose.tools import eq_ as eq
 from nose.plugins.attrib import attr
@@ -791,3 +792,14 @@ def test_zonegroup_remove():
 
     # validate the resulting period
     zonegroup.period.update(z1, commit=True)
+
+def test_set_bucket_website():
+    buckets, zone_bucket = create_bucket_per_zone_in_realm()
+    for _, bucket in zone_bucket:
+        website_cfg = WebsiteConfiguration(suffix='index.html',error_key='error.html')
+        try:
+            bucket.set_website_configuration(website_cfg)
+        except boto.exception.S3ResponseError as e:
+            if e.error_code == 'MethodNotAllowed':
+                raise SkipTest("test_set_bucket_website skipped. Requires rgw_enable_static_website = 1.")
+        assert(bucket.get_website_configuration_with_xml()[1] == website_cfg.to_xml())
\ No newline at end of file