diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index cd87c272ee3..9f28b313c3a 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1962,6 +1962,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 3589fb48985..2d8dc4edd35 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 1cca4cc8371..f6bbe9da59b 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -847,6 +847,9 @@ int RGWSetBucketWebsite_ObjStore_S3::get_params() return r; } + 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 fff682d37e4..58426dfbfe1 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