]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/cloud-tier: Redefining cloud tier types
authorSoumya Koduri <skoduri@redhat.com>
Wed, 12 Mar 2025 13:54:56 +0000 (19:24 +0530)
committerSoumya Koduri <skoduri@redhat.com>
Sat, 15 Mar 2025 16:13:13 +0000 (21:43 +0530)
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
src/rgw/driver/rados/rgw_obj_manifest.cc
src/rgw/driver/rados/rgw_obj_manifest.h
src/rgw/driver/rados/rgw_putobj_processor.cc
src/rgw/radosgw-admin/radosgw-admin.cc
src/rgw/rgw_zone_types.h

index b75411424590a7243ce52446153565dad72f5277..b38d66cff9f7fa598645d087c01f227e7e163a19 100644 (file)
@@ -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);
   }
 
index 1d66a1e437b519e5113deace67f2ca59da8ed61f..6a8a4e5121e851001610a82a538f6614d44f159c 100644 (file)
@@ -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;
 
index 95ca28290e74a3e3e912199ba9cea1d4475770ac..8ce92a0dffb838895cabbf5297516bb04f738e27 100644 (file)
@@ -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);
 
index bd6087020363b7e096ede3a50eca80a3feffe7c2..b886d59f68d6543977c95df2174a2632d712c1ff 100644 (file)
@@ -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;
index 197e23812d3c2fe75c30fc730f5afb7e4d685d61..4957635522b4d8e9189322a8bf4d24c10748b265 100644 (file)
@@ -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<RGWZoneGroupPlacementTier*>& 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<RGWZoneGroupPlacementTarget*>& 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)