]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/CloudTransition: Delete cloud tiered objects by default
authorSoumya Koduri <skoduri@redhat.com>
Sun, 2 Aug 2020 19:54:19 +0000 (01:24 +0530)
committerSoumya Koduri <skoduri@redhat.com>
Thu, 18 Nov 2021 07:22:47 +0000 (12:52 +0530)
Added a new option "retain_object" in tier_config which determines
whether a cloud tiered object is deleted or if its head object is
retained. By default the value is false i.e, the objects get
deleted.

XXX: verify that if Object is locked (ATTR_RETENTION), transition is
not processed. Also check if the transition takes place separately for
each version.

Signed-off-by: Soumya Koduri <skoduri@redhat.com>
src/rgw/rgw_cr_rest.h
src/rgw/rgw_json_enc.cc
src/rgw/rgw_lc.cc
src/rgw/rgw_zone.cc
src/rgw/rgw_zone.h

index 46d050c5cd763dc6b6af74778763460b25cae740..f6df68ddc9dd7c848012f59460cc7fc63426971b 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "rgw_coroutine.h"
 #include "rgw_rest_conn.h"
+#include "rgw_rados.h"
 
 
 struct rgw_rest_obj {
index c37f7098e39375add8210a926b9193e022669c64..c054c12bb3c9e66e51a7f227f7216fc372474f23 100644 (file)
@@ -1462,6 +1462,7 @@ void RGWZoneGroupPlacementTier::dump(Formatter *f) const
   encode_json("acl_mappings", acl_mappings, f);
   encode_json("multipart_sync_threshold", multipart_sync_threshold, f);
   encode_json("multipart_min_part_size", multipart_min_part_size, f);
+  encode_json("retain_object", retain_object, f);
 }
 
 void RGWZoneGroupPlacementTier::decode_json(JSONObj *obj)
@@ -1483,6 +1484,7 @@ void RGWZoneGroupPlacementTier::decode_json(JSONObj *obj)
   JSONDecoder::decode_json("acl_mappings", acl_mappings, obj);
   JSONDecoder::decode_json("multipart_sync_threshold", multipart_sync_threshold, obj);
   JSONDecoder::decode_json("multipart_min_part_size", multipart_min_part_size, obj);
+  JSONDecoder::decode_json("retain_object", retain_object, obj);
 }
 
 void RGWZoneGroupPlacementTarget::dump(Formatter *f) const
index bbeef3c4f257553a9ed21a362cd275a305f48582..dc33345ef157fb80e780b6f6c159bc7fd75da6d8 100644 (file)
@@ -1274,12 +1274,23 @@ public:
    return 0;
  }
 
+  int delete_tier_obj(lc_op_ctx& oc, RGWLCCloudTierCtx& tier_ctx) {
+    int ret = -1;
+
+    /* XXX: do we need to check for retention/versioning attributes
+     * as done in RGWDeleteObj?
+     */
+    ret = oc.store->getRados()->delete_obj(oc.rctx, oc.bucket_info, oc.obj, 0);
+
+    return ret;
+  }
+
   int update_tier_obj(lc_op_ctx& oc, RGWLCCloudTierCtx& tier_ctx) {
 
     map<string, bufferlist> attrs;
     RGWRados::Object op_target(tier_ctx.store->getRados(),
                                tier_ctx.bucket_info,
-                                tier_ctx.rctx, tier_ctx.obj);
+                               tier_ctx.rctx, tier_ctx.obj);
 
     RGWRados::Object::Read read_op(&op_target);
 
@@ -1387,10 +1398,18 @@ public:
       return ret;
     }
 
-    ret = update_tier_obj(oc, tier_ctx);
-    if (ret < 0) {
-      ldpp_dout(oc.dpp, 0) << "Updating tier object failed ret=" << ret << dendl;
-      return ret;
+    if (oc.tier.retain_object) {
+      ret = update_tier_obj(oc, tier_ctx);
+      if (ret < 0) {
+        ldpp_dout(oc.dpp, 0) << "Updating tier object failed ret=" << ret << dendl;
+        return ret;
+      }
+    } else {
+      ret = delete_tier_obj(oc, tier_ctx);
+      if (ret < 0) {
+        ldpp_dout(oc.dpp, 0) << "Deleting tier object failed ret=" << ret << dendl;
+        return ret;
+      }
     }
 
     return 0;
index 578b4f81bf3f2062b047314949536d88981b1583..aa9c47ad40cfdad9f5f1499b4fce93b66b5e41b2 100644 (file)
@@ -2123,6 +2123,14 @@ int RGWZoneGroupPlacementTier::update_params(const JSONFormattable& config)
   if (config.exists("secret")) {
     key.key = config["secret"];
   }
+  if (config.exists("retain_object")) {
+    string s = config["retain_object"];
+    if (s == "true") {
+      retain_object = true;
+    } else {
+      retain_object = false;
+    }
+  }
 
   if (config.exists("multipart_sync_threshold")) {
     r = conf_to_uint64(config, "multipart_sync_threshold", &multipart_sync_threshold);
@@ -2179,6 +2187,9 @@ int RGWZoneGroupPlacementTier::clear_params(const JSONFormattable& config)
   if (config.exists("secret")) {
     key.key.clear();
   }
+  if (config.exists("retain_object")) {
+    retain_object = false;
+  }
   if (config.exists("multipart_sync_threshold")) {
     multipart_sync_threshold = DEFAULT_MULTIPART_SYNC_PART_SIZE;
   }
index 886e63ed93b7bf736faeb2e27c5c44eddc28cc14..ab93a9c40e9857dce59554393c42bb1568e94975 100644 (file)
@@ -763,6 +763,8 @@ struct RGWZoneGroupPlacementTier {
   uint64_t multipart_sync_threshold{DEFAULT_MULTIPART_SYNC_PART_SIZE};
   uint64_t multipart_min_part_size{DEFAULT_MULTIPART_SYNC_PART_SIZE};
 
+  bool retain_object = false;
+
   int update_params(const JSONFormattable& config);
   int clear_params(const JSONFormattable& config);
 
@@ -779,6 +781,7 @@ struct RGWZoneGroupPlacementTier {
     encode(acl_mappings, bl);
     encode(multipart_sync_threshold, bl);
     encode(multipart_min_part_size, bl);
+    encode(retain_object, bl);
     ENCODE_FINISH(bl);
   }
 
@@ -800,6 +803,7 @@ struct RGWZoneGroupPlacementTier {
     decode(acl_mappings, bl);
     decode(multipart_sync_threshold, bl);
     decode(multipart_min_part_size, bl);
+    decode(retain_object, bl);
     DECODE_FINISH(bl);
   }
   void dump(Formatter *f) const;