From: Soumya Koduri Date: Sun, 2 Aug 2020 19:54:19 +0000 (+0530) Subject: rgw/CloudTransition: Delete cloud tiered objects by default X-Git-Tag: v17.1.0~411^2~12 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7d7aeb1ee04a0c40e943f8284c604dd3a9e4e275;p=ceph.git rgw/CloudTransition: Delete cloud tiered objects by default 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 --- diff --git a/src/rgw/rgw_cr_rest.h b/src/rgw/rgw_cr_rest.h index 46d050c5cd763..f6df68ddc9dd7 100644 --- a/src/rgw/rgw_cr_rest.h +++ b/src/rgw/rgw_cr_rest.h @@ -9,6 +9,7 @@ #include "rgw_coroutine.h" #include "rgw_rest_conn.h" +#include "rgw_rados.h" struct rgw_rest_obj { diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index c37f7098e3937..c054c12bb3c9e 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -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 diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index bbeef3c4f2575..dc33345ef157f 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -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 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; diff --git a/src/rgw/rgw_zone.cc b/src/rgw/rgw_zone.cc index 578b4f81bf3f2..aa9c47ad40cfd 100644 --- a/src/rgw/rgw_zone.cc +++ b/src/rgw/rgw_zone.cc @@ -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; } diff --git a/src/rgw/rgw_zone.h b/src/rgw/rgw_zone.h index 886e63ed93b7b..ab93a9c40e985 100644 --- a/src/rgw/rgw_zone.h +++ b/src/rgw/rgw_zone.h @@ -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;