From: yuliyang Date: Mon, 15 May 2017 08:49:13 +0000 (+0800) Subject: rgw-multisite: fix the problem of rgw website configure request not redirect to metad... X-Git-Tag: v12.1.0~133^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F15082%2Fhead;p=ceph.git rgw-multisite: fix the problem of rgw website configure request not redirect to metadata master Signed-off-by: yuliyang --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 29adbc58aa48..57e3235c3b1b 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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; diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 3589fb489855..2d8dc4edd352 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -748,6 +748,7 @@ public: class RGWSetBucketWebsite : public RGWOp { protected: + bufferlist in_data; RGWBucketWebsiteConf website_conf; public: RGWSetBucketWebsite() {} diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 0b2550d704b2..684e65a66cee 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -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; diff --git a/src/test/rgw/rgw_multi/tests.py b/src/test/rgw/rgw_multi/tests.py index fff682d37e49..58426dfbfe1b 100644 --- a/src/test/rgw/rgw_multi/tests.py +++ b/src/test/rgw/rgw_multi/tests.py @@ -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