]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix response of delete expired objects 6228/head
authorYuan Zhou <yuan.zhou@intel.com>
Wed, 14 Oct 2015 07:54:27 +0000 (15:54 +0800)
committerYuan Zhou <yuan.zhou@intel.com>
Wed, 14 Oct 2015 07:54:27 +0000 (15:54 +0800)
GET/HEAD requests to the expired-but-not-yet-deleted objects will
'404 Not Found' currently.

Swift's response to a DELETE of an expired object is 404; however,
the object does get deleted.

This patch fixes this issue by checking the expire time in Swift DELETE
op, delete the object with a 404 http code.

Fixes #13469

Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>
src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_rest_swift.h

index e05ad976e4e41b7edab6ae4fba1dbfae94a3837d..a73a3248153c8e06d6c2e20c55ecede9ffe11266 100644 (file)
@@ -2428,7 +2428,16 @@ void RGWDeleteObj::execute()
 {
   ret = -EINVAL;
   rgw_obj obj(s->bucket, s->object);
+  map<string, bufferlist> orig_attrs;
+
   if (!s->object.empty()) {
+    if (need_object_expiration()) {
+      /* check if obj exists, read orig attrs */
+      ret = get_obj_attrs(store, s, obj, orig_attrs);
+      if (ret < 0) {
+        return;
+      }
+    }
     RGWObjectCtx *obj_ctx = static_cast<RGWObjectCtx *>(s->obj_ctx);
 
     obj_ctx->set_atomic(obj);
@@ -2449,6 +2458,13 @@ void RGWDeleteObj::execute()
       delete_marker = del_op.result.delete_marker;
       version_id = del_op.result.version_id;
     }
+
+    /* Check whether the object has expired. Swift API documentation
+     * stands that we should return 404 Not Found in such case. */
+    if (need_object_expiration() && object_is_expired(orig_attrs)) {
+      ret = -ENOENT;
+      return;
+    }
   }
 }
 
index 0cdca94b4a29cdbde06b03a53560912f3fd2ee3f..bdb248233d7ebf3e212916bc5f2878f51cb6ae7f 100644 (file)
@@ -625,6 +625,7 @@ public:
   virtual const string name() { return "delete_obj"; }
   virtual RGWOpType get_type() { return RGW_OP_DELETE_OBJ; }
   virtual uint32_t op_mask() { return RGW_OP_TYPE_DELETE; }
+  virtual bool need_object_expiration() { return false; }
 };
 
 class RGWCopyObj : public RGWOp {
index 1311dadb29d138eaabdb3ea820dc9af1e6890859..400b27475465c40822de6b1e37ca7d088f506558 100644 (file)
@@ -124,6 +124,7 @@ public:
   RGWDeleteObj_ObjStore_SWIFT() {}
   ~RGWDeleteObj_ObjStore_SWIFT() {}
 
+  bool need_object_expiration() { return true; }
   void send_response();
 };