From: Soumya Koduri Date: Wed, 12 Mar 2025 13:54:56 +0000 (+0530) Subject: rgw/cloud-tier: Redefining cloud tier types X-Git-Tag: v20.3.0~299^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=38d2c11bf24c347b2e27d17476528132d2bd0233;p=ceph.git rgw/cloud-tier: Redefining cloud tier types Signed-off-by: Soumya Koduri --- diff --git a/src/rgw/driver/rados/rgw_obj_manifest.cc b/src/rgw/driver/rados/rgw_obj_manifest.cc index b75411424590a..b38d66cff9f7f 100644 --- a/src/rgw/driver/rados/rgw_obj_manifest.cc +++ b/src/rgw/driver/rados/rgw_obj_manifest.cc @@ -347,7 +347,7 @@ void RGWObjManifest::dump(Formatter *f) const ::encode_json("tail_placement", tail_placement, f); ::encode_json("tier_type", tier_type, f); - if (tier_type == "cloud-s3" || tier_type == "cloud-s3-glacier") { + if (RGWTierType::is_tier_type_supported(tier_type)) { ::encode_json("tier_config", tier_config, f); } diff --git a/src/rgw/driver/rados/rgw_obj_manifest.h b/src/rgw/driver/rados/rgw_obj_manifest.h index 1d66a1e437b51..6a8a4e5121e85 100644 --- a/src/rgw/driver/rados/rgw_obj_manifest.h +++ b/src/rgw/driver/rados/rgw_obj_manifest.h @@ -472,22 +472,25 @@ public: } bool is_tier_type_s3() { - return (tier_type == "cloud-s3" || tier_type == "cloud-s3-glacier"); + return (tier_type == RGWTierType::CLOUD_S3 || + tier_type == RGWTierType::CLOUD_S3_GLACIER); } bool is_tier_type_s3_glacier() { - return (tier_type == "cloud-s3-glacier"); + return (tier_type == RGWTierType::CLOUD_S3_GLACIER); } inline void set_tier_type(std::string value) { - /* Only "cloud-s3" & "cloud-s3-glacier" tier-type is supported for now */ - if (value == "cloud-s3" || value == "cloud-s3-glacier") { + /* Only RGWTierType::CLOUD_S3 & RGWTierType::CLOUD_S3_GLACIER + * tier-type are supported for now */ + if (RGWTierType::is_tier_type_supported(value)) { tier_type = value; } } inline void set_tier_config(RGWObjTier t) { - /* Set only if tier_type set to "cloud-s3" or "cloud-s3-glacier" */ + /* Set only if tier_type set to RGWTierType::CLOUD_S3 or + * RGWTierType::CLOUD_S3_GLACIER */ if (!is_tier_type_s3()) return; diff --git a/src/rgw/driver/rados/rgw_putobj_processor.cc b/src/rgw/driver/rados/rgw_putobj_processor.cc index 95ca28290e74a..8ce92a0dffb83 100644 --- a/src/rgw/driver/rados/rgw_putobj_processor.cc +++ b/src/rgw/driver/rados/rgw_putobj_processor.cc @@ -45,7 +45,7 @@ int read_cloudtier_info_from_attrs(rgw::sal::Attrs& attrs, RGWObjCategory& categ auto i = attr_iter->second; string m = i.to_str(); - if (m == "cloud-s3" || m == "cloud-s3-glacier") { + if (RGWTierType::is_tier_type_supported(m)) { category = RGWObjCategory::CloudTiered; manifest.set_tier_type(m); diff --git a/src/rgw/radosgw-admin/radosgw-admin.cc b/src/rgw/radosgw-admin/radosgw-admin.cc index bd6087020363b..b886d59f68d65 100644 --- a/src/rgw/radosgw-admin/radosgw-admin.cc +++ b/src/rgw/radosgw-admin/radosgw-admin.cc @@ -5937,7 +5937,7 @@ int main(int argc, const char **argv) pt = &ptiter->second; tier_class = true; } else if (tier_type_specified) { - if (tier_type == "cloud-s3" || tier_type == "cloud-s3-glacier") { + if (RGWTierType::is_tier_type_supported(tier_type)) { /* we support only cloud-s3 & cloud-s3-glacier tier-type for now. * Once set cant be reset. */ tier_class = true; diff --git a/src/rgw/rgw_zone_types.h b/src/rgw/rgw_zone_types.h index 197e23812d3c2..4957635522b4d 100644 --- a/src/rgw/rgw_zone_types.h +++ b/src/rgw/rgw_zone_types.h @@ -578,6 +578,16 @@ struct RGWZoneGroupTierS3Glacier { }; WRITE_CLASS_ENCODER(RGWZoneGroupTierS3Glacier) + +struct RGWTierType { + static constexpr const char* CLOUD_S3 = "cloud-s3"; + static constexpr const char* CLOUD_S3_GLACIER = "cloud-s3-glacier"; + + static bool is_tier_type_supported(const std::string& t) { + return ((t == CLOUD_S3) || (t == CLOUD_S3_GLACIER)); + } +}; + struct RGWZoneGroupPlacementTier { #define DEFAULT_READ_THROUGH_RESTORE_DAYS 1 @@ -621,13 +631,13 @@ struct RGWZoneGroupPlacementTier { decode(storage_class, bl); decode(retain_head_object, bl); if (struct_v == 1) { - if (tier_type == "cloud-s3") { + if (tier_type == RGWTierType::CLOUD_S3) { decode(t.s3, bl); } } else if (struct_v == 2) { decode(allow_read_through, bl); decode(read_through_restore_days, bl); - if (tier_type == "cloud-s3") { + if (tier_type == RGWTierType::CLOUD_S3) { decode(t.s3, bl); } } else if (struct_v >= 3) { @@ -647,11 +657,12 @@ struct RGWZoneGroupPlacementTier { } bool is_tier_type_s3() const { - return (tier_type == "cloud-s3" || tier_type == "cloud-s3-glacier"); + return (tier_type == RGWTierType::CLOUD_S3 || + tier_type == RGWTierType::CLOUD_S3_GLACIER); } bool is_tier_type_s3_glacier() const { - return (tier_type == "cloud-s3-glacier"); + return (tier_type == RGWTierType::CLOUD_S3_GLACIER); } void dump(Formatter *f) const; @@ -659,10 +670,10 @@ struct RGWZoneGroupPlacementTier { static void generate_test_instances(std::list& o) { o.push_back(new RGWZoneGroupPlacementTier); o.push_back(new RGWZoneGroupPlacementTier); - o.back()->tier_type = "cloud-s3"; - o.back()->storage_class = "STANDARD"; + o.back()->tier_type = RGWTierType::CLOUD_S3; + o.back()->storage_class = RGW_STORAGE_CLASS_STANDARD; o.back()->allow_read_through = false; - o.back()->restore_storage_class = "STANDARD"; + o.back()->restore_storage_class = RGW_STORAGE_CLASS_STANDARD; o.back()->s3_glacier.glacier_restore_days = 2; o.back()->s3_glacier.glacier_restore_tier_type = GlacierRestoreTierType::Expedited; } @@ -715,14 +726,14 @@ struct RGWZoneGroupPlacementTarget { void decode_json(JSONObj *obj); static void generate_test_instances(std::list& o) { o.push_back(new RGWZoneGroupPlacementTarget); - o.back()->storage_classes.insert("STANDARD"); + o.back()->storage_classes.insert(RGW_STORAGE_CLASS_STANDARD); o.push_back(new RGWZoneGroupPlacementTarget); o.back()->name = "target"; o.back()->tags.insert("tag1"); o.back()->tags.insert("tag2"); o.back()->storage_classes.insert("STANDARD_IA"); - o.back()->tier_targets["cloud-s3"].tier_type = "cloud-s3"; - o.back()->tier_targets["cloud-s3"].storage_class = "STANDARD"; + o.back()->tier_targets[RGWTierType::CLOUD_S3].tier_type = RGWTierType::CLOUD_S3; + o.back()->tier_targets[RGWTierType::CLOUD_S3].storage_class = RGW_STORAGE_CLASS_STANDARD; } }; WRITE_CLASS_ENCODER(RGWZoneGroupPlacementTarget)