]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: website routing rules num limit 23429/head
authoryuliyang <yuliyang@cmss.chinamobile.com>
Sun, 5 Aug 2018 08:36:59 +0000 (16:36 +0800)
committeryuliyang <yuliyang@cmss.chinamobile.com>
Thu, 20 Sep 2018 00:50:32 +0000 (08:50 +0800)
According to AWS S3 , an website routing rules can
have up to 50 rules.

Signed-off-by: yuliyang <yuliyang@cmss.chinamobile.com>
src/common/legacy_config_opts.h
src/common/options.cc
src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_rest_s3.cc

index b2a82b39a442d8e89cb442f3d286b46f15039d80..61100c7e5356a875b5afe9b3f31ec80db5568d6e 100644 (file)
@@ -1546,3 +1546,4 @@ OPTION(rgw_reshard_thread_interval, OPT_U32) // maximum time between rounds of r
 OPTION(rgw_acl_grants_max_num, OPT_INT) // According to AWS S3(http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html), An ACL can have up to 100 grants.
 OPTION(rgw_cors_rules_max_num, OPT_INT) // According to AWS S3(http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html), An cors can have up to 100 rules.
 OPTION(rgw_delete_multi_obj_max_num, OPT_INT) // According to AWS S3(https://docs.aws.amazon.com/AmazonS3/latest/dev/DeletingObjects.html), Amazon S3 also provides the Multi-Object Delete API that you can use to delete up to 1000 objects in a single HTTP request.
+OPTION(rgw_website_routing_rules_max_num, OPT_INT) // According to AWS S3, An website routing config can have up to 50 rules.
index b92d31971a7555e1967933c7efdf4adf72530424..6bc7842f9d4b8dde15cb52377ab15a33763b651d 100644 (file)
@@ -4996,6 +4996,10 @@ std::vector<Option> get_rgw_options() {
     .set_default(1000)
     .set_description("Max number of objects in a single multi-object delete request"),
 
+    Option("rgw_website_routing_rules_max_num", Option::TYPE_INT, Option::LEVEL_ADVANCED)
+    .set_default(50)
+    .set_description("Max number of website routing rules in a single request"),
+
     Option("rgw_rados_tracing", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
     .set_default(false)
     .set_description("true if LTTng-UST tracepoints should be enabled"),
index c66a3d53e52eb456e1729a2c5faf34cee3aa9249..beb06d7ed8494223d43cbb63356bd0464c1efc16 100644 (file)
@@ -76,6 +76,7 @@ rgw_http_errors rgw_http_s3_errors({
     { ERR_INVALID_TAG, {400, "InvalidTag"}},
     { ERR_MALFORMED_ACL_ERROR, {400, "MalformedACLError" }},
     { ERR_INVALID_CORS_RULES_ERROR, {400, "InvalidRequest" }},
+    { ERR_INVALID_WEBSITE_ROUTING_RULES_ERROR, {400, "InvalidRequest" }},
     { ERR_INVALID_ENCRYPTION_ALGORITHM, {400, "InvalidEncryptionAlgorithmError" }},
     { ERR_LENGTH_REQUIRED, {411, "MissingContentLength" }},
     { EACCES, {403, "AccessDenied" }},
index ab0b61db7989f9f46c18486cd6dea9e1e8e1d633..0ae4583fe45deb628f402da892cbcfac19ae0caa 100644 (file)
@@ -219,6 +219,7 @@ using ceph::crypto::MD5;
 #define ERR_INVALID_ENCRYPTION_ALGORITHM                 2214
 #define ERR_INVALID_CORS_RULES_ERROR                     2215
 #define ERR_NO_CORS_FOUND        2216
+#define ERR_INVALID_WEBSITE_ROUTING_RULES_ERROR          2217
 
 #define ERR_BUSY_RESHARDING      2300
 #define ERR_NO_SUCH_ENTITY       2301
index 0e25e10e2f9d604106451556ec649a86256730d1..3ca4e650003085cf9581c27bab47057221dc437a 100644 (file)
@@ -1037,6 +1037,24 @@ int RGWSetBucketWebsite_ObjStore_S3::get_params()
     return -EINVAL;
   }
 
+#define WEBSITE_ROUTING_RULES_MAX_NUM      50
+  int max_num = s->cct->_conf->rgw_website_routing_rules_max_num;
+  if (max_num < 0) {
+    max_num = WEBSITE_ROUTING_RULES_MAX_NUM;
+  }
+  int routing_rules_num = website_conf.routing_rules.rules.size();
+  if (routing_rules_num > max_num) {
+    ldout(s->cct, 4) << "An website routing config can have up to "
+                     << max_num
+                     << " rules, request website routing rules num: "
+                     << routing_rules_num << dendl;
+    op_ret = -ERR_INVALID_WEBSITE_ROUTING_RULES_ERROR;
+    s->err.message = std::to_string(routing_rules_num) +" routing rules provided, the number of routing rules in a website configuration is limited to "
+                     + std::to_string(max_num)
+                     + ".";
+    return -ERR_INVALID_REQUEST;
+  }
+
   return 0;
 }