]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: return "NoSuchLifecycleConfiguration" if lc config does not exist 10442/head
authorweiqiaomiao <wei.qiaomiao@zte.com.cn>
Tue, 26 Jul 2016 10:03:31 +0000 (18:03 +0800)
committerweiqiaomiao <wei.qiaomiao@zte.com.cn>
Tue, 26 Jul 2016 10:09:33 +0000 (18:09 +0800)
return error code "NoSuchLifecycleConfiguration" if lifecycle configuration does not exist
as AmazonS3 latest API does.

Signed-off-by: weiqiaomiao <wei.qiaomiao@zte.com.cn>
src/rgw/rgw_common.h
src/rgw/rgw_http_errors.h
src/rgw/rgw_rest_s3.cc

index 8f551cdaa3025ed61bef98a94b6383f20c2af062..e6f0346e448f482ee28989f9e4a0ab9cb495ed61 100644 (file)
@@ -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
index 4e6107e1e4dc460829d3e22e74a02cdd1a0bd148..dd83a1efd3bd16698b1ff56941cd60c007357184 100644 (file)
@@ -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" },
index 5c4b67930e865e5c33f119eb39311f4cb3328750..1bcdef14b24a66c0d274c5bc757d3371640b4291 100644 (file)
@@ -2265,34 +2265,34 @@ void RGWPutACLs_ObjStore_S3::send_response()
 
 void RGWGetLC_ObjStore_S3::execute()
 {
-  map<string, bufferlist> bucket_attrs;
 
   config.set_ctx(s->cct);
 
-  RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(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<string, bufferlist>::iterator aiter = s->bucket_attrs.find(RGW_ATTR_LC);
+  if (aiter == s->bucket_attrs.end()) {
+    ret = -ENOENT;
     return;
   }
 
-  map<string, bufferlist>::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);