]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: complete expiration header (object tags)
authorMatt Benjamin <mbenjamin@redhat.com>
Tue, 19 Feb 2019 16:17:45 +0000 (11:17 -0500)
committerYuval Lifshitz <yuvalif@yahoo.com>
Tue, 3 Mar 2020 11:19:42 +0000 (13:19 +0200)
The expiration header tag processing is complete, but the
passed RGWObjTags argument was never initialized.  Now it is
initialized in RGWGetObj and RGWPutObj, as required.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
(cherry picked from commit 8981c5e9f688b13a00345e069c2ce1e62fb0a588)
Signed-off-by: Yuval Lifshitz <yuvalif@yahoo.com>
src/rgw/rgw_lc.cc
src/rgw/rgw_op.cc

index 3089f5282a164b2227a36b34f7cc011bc81a005f..1bb9330bb243a7ddbe35f7589e90c4a0f55ea3ca 100644 (file)
@@ -1535,7 +1535,7 @@ std::string s3_expiration_header(
   const std::map<std::string, buffer::list>& bucket_attrs)
 {
   CephContext* cct = dpp->get_cct();
-  RGWLifecycleConfiguration config(cct); // TODO: save in bucket info
+  RGWLifecycleConfiguration config(cct);
   std::string hdr{""};
 
   const auto& aiter = bucket_attrs.find(RGW_ATTR_LC);
@@ -1638,8 +1638,7 @@ std::string s3_expiration_header(
     // update earliest expiration
     if (rule_expiration_date) {
       if ((! expiration_date) ||
-         ((expiration_date &&
-           (*expiration_date < *rule_expiration_date)))) {
+         (*expiration_date < *rule_expiration_date)) {
       expiration_date =
        boost::optional<ceph::real_time>(rule_expiration_date);
       }
index 239974d01050d08c55abcfa89e51bfb14f28ead3..52d1f2dd63552b94b87f8f51383c9383e0b41b9a 100644 (file)
@@ -1972,6 +1972,22 @@ static bool object_is_expired(map<string, bufferlist>& attrs) {
   return false;
 }
 
+static inline void rgw_cond_decode_objtags(
+  struct req_state *s,
+  const std::map<std::string, buffer::list> &attrs)
+{
+  const auto& tags = attrs.find(RGW_ATTR_TAGS);
+  if (tags != attrs.end()) {
+    try {
+      bufferlist::const_iterator iter{&tags->second};
+      s->tagset.decode(iter);
+    } catch (buffer::error& err) {
+      ldout(s->cct, 0)
+       << "ERROR: caught buffer::error, couldn't decode TagSet" << dendl;
+    }
+  }
+}
+
 void RGWGetObj::execute()
 {
   bufferlist bl;
@@ -2102,6 +2118,9 @@ void RGWGetObj::execute()
     goto done_err;
   }
 
+  /* Decode S3 objtags, if any */
+  rgw_cond_decode_objtags(s, attrs);
+
   start = ofs;
 
   attr_iter = attrs.find(RGW_ATTR_MANIFEST);
@@ -3925,6 +3944,7 @@ void RGWPutObj::execute()
   }
   encode_delete_at_attr(delete_at, attrs);
   encode_obj_tags_attr(obj_tags.get(), attrs);
+  rgw_cond_decode_objtags(s, attrs);
 
   /* Add a custom metadata to expose the information whether an object
    * is an SLO or not. Appending the attribute must be performed AFTER