]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix bucket location s3 compatible issue
authorJiaying Ren <jiaying.ren@umcloud.com>
Thu, 25 May 2017 10:50:37 +0000 (18:50 +0800)
committerJiaying Ren <jiaying.ren@umcloud.com>
Sun, 18 Jun 2017 03:24:43 +0000 (11:24 +0800)
create bucket with location constraint doesn't exist in AWS S3
will response like the following:

{'data': '<?xml version="1.0" encoding="UTF-8"?>\n
<Error><Code>InvalidLocationConstraint</Code>
<Message>The specified location-constraint is not valid</Message>
<LocationConstraint>ap-southeast-4</LocationConstraint>
<RequestId>15D886DFEF49765A</RequestId>
<HostId>IroSlmBZq7iSluYIgea7y+72OXbOSmjX2eVYING0tUuGR8BAHLcYPOgUWUIJUuG1z/1FhfaxJUo=</HostId></Error>',
 'headers': {'connection': 'close',
             'content-type': 'application/xml',
             'date': 'Thu, 25 May 2017 03:45:49 GMT',
             'server': 'AmazonS3',
             'transfer-encoding': 'chunked',
             'x-amz-id-2': 'IroSlmBZq7iSluYIgea7y+72OXbOSmjX2eVYING0tUuGR8BAHLcYPOgUWUIJUuG1z/1FhfaxJUo=',
             'x-amz-request-id': '15D886DFEF49765A'},
 'reason': 'Bad Request',
 'status': 400}

Signed-off-by: Jiaying Ren <jiaying.ren@umcloud.com>
src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_op.cc

index 708e95b59cdc0c61fd8f3640f0455c0ac8265a01..b6b38fbb46e99cb84b07a463a158fb2fa2d023d4 100644 (file)
@@ -61,6 +61,7 @@ rgw_http_errors rgw_http_s3_errors({
     { ERR_INVALID_REQUEST, {400, "InvalidRequest" }},
     { ERR_INVALID_DIGEST, {400, "InvalidDigest" }},
     { ERR_BAD_DIGEST, {400, "BadDigest" }},
+    { ERR_INVALID_LOCATION_CONSTRAINT, {400, "InvalidLocationConstraint" }},
     { ERR_INVALID_BUCKET_NAME, {400, "InvalidBucketName" }},
     { ERR_INVALID_OBJECT_NAME, {400, "InvalidObjectName" }},
     { ERR_UNRESOLVABLE_EMAIL, {400, "UnresolvableGrantByEmailAddress" }},
index 6ed3a76c3f7cfdd9a831c7e23489b3dd3483b6bf..b9fdccc606b0f9b79e6f56fca623fc3cd45d3a83 100644 (file)
@@ -205,6 +205,8 @@ using ceph::crypto::MD5;
 #define ERR_NO_ROLE_FOUND        2205
 #define ERR_DELETE_CONFLICT      2206
 #define ERR_NO_SUCH_BUCKET_POLICY  2207
+#define ERR_INVALID_LOCATION_CONSTRAINT 2208
+
 #define ERR_BUSY_RESHARDING      2300
 
 #ifndef UINT32_MAX
index 9f28b313c3a98b5ede3256b63b358120d1c23183..58c700993f703651c1d2ff7533a333406084ecf3 100644 (file)
@@ -2396,8 +2396,11 @@ void RGWCreateBucket::execute()
 
   if (!store->get_zonegroup().is_master &&
       store->get_zonegroup().api_name != location_constraint) {
-    ldout(s->cct, 0) << "location constraint (" << location_constraint << ") doesn't match zonegroup" << " (" << store->get_zonegroup().api_name << ")" << dendl;
-    op_ret = -EINVAL;
+    ldout(s->cct, 0) << "location constraint (" << location_constraint << ")"
+                     << " doesn't match zonegroup" << " (" << store->get_zonegroup().api_name << ")"
+                     << dendl;
+    op_ret = -ERR_INVALID_LOCATION_CONSTRAINT;
+    s->err.message = "The specified location-constraint is not valid";
     return;
   }