From db13592398ed5872dbb4d1b44b821926ffa5397c Mon Sep 17 00:00:00 2001 From: Jiaying Ren Date: Thu, 25 May 2017 18:50:37 +0800 Subject: [PATCH] rgw: fix bucket location s3 compatible issue create bucket with location constraint doesn't exist in AWS S3 will response like the following: {'data': '\n InvalidLocationConstraint The specified location-constraint is not valid ap-southeast-4 15D886DFEF49765A IroSlmBZq7iSluYIgea7y+72OXbOSmjX2eVYING0tUuGR8BAHLcYPOgUWUIJUuG1z/1FhfaxJUo=', '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 --- src/rgw/rgw_common.cc | 1 + src/rgw/rgw_common.h | 2 ++ src/rgw/rgw_op.cc | 7 +++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 708e95b59cd..b6b38fbb46e 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -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" }}, diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 6ed3a76c3f7..b9fdccc606b 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -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 diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 9f28b313c3a..58c700993f7 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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; } -- 2.39.5