]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: return proper etag in response for PUT on Swift's SLO.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Wed, 24 Feb 2016 13:28:58 +0000 (14:28 +0100)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 29 Feb 2016 11:16:42 +0000 (12:16 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_rest_swift.cc
src/rgw/rgw_rest_swift.h

index 49aa79e62f738ca4b4b820ac7753d8f98ac90f83..61667103a3d76446069ebc2dc32596949e004932 100644 (file)
@@ -603,11 +603,19 @@ int RGWPutObj_ObjStore_SWIFT::get_params()
       return -EINVAL;
     }
 
+    MD5 etag_sum;
     uint64_t total_size = 0;
-    for (vector<rgw_slo_entry>::iterator iter = slo_info->entries.begin(); iter != slo_info->entries.end(); ++iter) {
-      total_size += iter->size_bytes;
-      ldout(s->cct, 20) << "slo_part: " << iter->path << " size=" << iter->size_bytes << dendl;
+    for (const auto& entry : slo_info->entries) {
+      etag_sum.Update((const byte *)entry.etag.c_str(),
+                      entry.etag.length());
+      total_size += entry.size_bytes;
+
+      ldout(s->cct, 20) << "slo_part: " << entry.path
+                        << " size=" << entry.size_bytes
+                        << " etag=" << entry.etag
+                        << dendl;
     }
+    complete_etag(etag_sum, &lo_etag);
     slo_info->total_size = total_size;
 
     ofs = slo_info->raw_data_len;
@@ -618,9 +626,24 @@ int RGWPutObj_ObjStore_SWIFT::get_params()
 
 void RGWPutObj_ObjStore_SWIFT::send_response()
 {
-  if (! op_ret)
+  if (! op_ret) {
     op_ret = STATUS_CREATED;
-  dump_etag(s, etag.c_str());
+  }
+
+  if (!lo_etag.empty()) {
+    /* Static Large Object of Swift API has two etags represented by
+     * following members:
+     *  - etag - for the manifest itself (it will be stored in xattrs),
+     *  - lo_etag - for the content composited from SLO's segments.
+     *    The value is calculated basing on segments' etags.
+     * In response for PUT request we have to expose the second one.
+     * The first one may be obtained by GET with "multipart-manifest=get"
+     * in query string on a given SLO. */
+    dump_etag(s, ("\"" + lo_etag + "\"").c_str());
+  } else {
+    dump_etag(s, etag.c_str());
+  }
+
   dump_last_modified(s, mtime);
   set_req_state_err(s, op_ret);
   dump_errno(s);
index 170f4fe78ba5040917cdac309999cd98a646005c..9d85eb6dd7598b6ffea080995106c8afe7bba1c6 100644 (file)
@@ -84,6 +84,7 @@ public:
 };
 
 class RGWPutObj_ObjStore_SWIFT : public RGWPutObj_ObjStore {
+  string lo_etag;
 public:
   RGWPutObj_ObjStore_SWIFT() {}
   ~RGWPutObj_ObjStore_SWIFT() {}