From: weiqiaomiao Date: Tue, 26 Jul 2016 10:03:31 +0000 (+0800) Subject: rgw: return "NoSuchLifecycleConfiguration" if lc config does not exist X-Git-Tag: ses5-milestone5~298^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b32b5f1c8760bf73c436eaef2c83c6cf140db900;p=ceph.git rgw: return "NoSuchLifecycleConfiguration" if lc config does not exist return error code "NoSuchLifecycleConfiguration" if lifecycle configuration does not exist as AmazonS3 latest API does. Signed-off-by: weiqiaomiao --- diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 8f551cdaa302..e6f0346e448f 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -185,6 +185,7 @@ using ceph::crypto::MD5; #define ERR_WEBSITE_REDIRECT 2038 #define ERR_NO_SUCH_WEBSITE_CONFIGURATION 2039 #define ERR_AMZ_CONTENT_SHA256_MISMATCH 2040 +#define ERR_NO_SUCH_LC 2041 #define ERR_USER_SUSPENDED 2100 #define ERR_INTERNAL_ERROR 2200 #define ERR_NOT_IMPLEMENTED 2201 diff --git a/src/rgw/rgw_http_errors.h b/src/rgw/rgw_http_errors.h index 4e6107e1e4dc..dd83a1efd3bd 100644 --- a/src/rgw/rgw_http_errors.h +++ b/src/rgw/rgw_http_errors.h @@ -50,6 +50,7 @@ const static struct rgw_http_errors RGW_HTTP_ERRORS[] = { { ERR_NO_SUCH_WEBSITE_CONFIGURATION, 404, "NoSuchWebsiteConfiguration" }, { ERR_NO_SUCH_UPLOAD, 404, "NoSuchUpload" }, { ERR_NOT_FOUND, 404, "Not Found"}, + { ERR_NO_SUCH_LC, 404, "NoSuchLifecycleConfiguration"}, { ERR_METHOD_NOT_ALLOWED, 405, "MethodNotAllowed" }, { ETIMEDOUT, 408, "RequestTimeout" }, { EEXIST, 409, "BucketAlreadyExists" }, diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 5c4b67930e86..1bcdef14b24a 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -2265,34 +2265,34 @@ void RGWPutACLs_ObjStore_S3::send_response() void RGWGetLC_ObjStore_S3::execute() { - map bucket_attrs; config.set_ctx(s->cct); - RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); - int ret = store->get_bucket_info(obj_ctx, s->bucket_tenant, s->bucket_name, s->bucket_info, NULL, &bucket_attrs); - if (ret < 0) { - ldout(s->cct, 0) << "LC:get_bucket_info failed" << s->bucket_name << dendl; + map::iterator aiter = s->bucket_attrs.find(RGW_ATTR_LC); + if (aiter == s->bucket_attrs.end()) { + ret = -ENOENT; return; } - map::iterator aiter = bucket_attrs.find(RGW_ATTR_LC); - if (aiter == bucket_attrs.end()) - return; - bufferlist::iterator iter(&aiter->second); try { config.decode(iter); } catch (const buffer::error& e) { ldout(s->cct, 0) << __func__ << "decode life cycle config failed" << dendl; + ret = -EIO; return; } } void RGWGetLC_ObjStore_S3::send_response() { - if (ret) - set_req_state_err(s, ret); + if (ret) { + if (ret == -ENOENT) { + set_req_state_err(s, ERR_NO_SUCH_LC); + } else { + set_req_state_err(s, ret); + } + } dump_errno(s); end_header(s, this, "application/xml"); dump_start(s);