]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/CloudTransition: Do not allow data pool for tier type storage classes
authorSoumya Koduri <skoduri@redhat.com>
Mon, 14 Dec 2020 18:26:16 +0000 (23:56 +0530)
committerSoumya Koduri <skoduri@redhat.com>
Thu, 18 Nov 2021 07:22:48 +0000 (12:52 +0530)
Tier type storage classes should not be allowed to have data
pools

& few other fixes/cleanup stated below -

* If the tier_targets are not configured, do not dump them in
the 'zonegroup get' command.

* If not configured, by default a bucket of below name convention -
"rgwx-$zonegroup-$storage_class-cloud-bucket"

is created in the remote cloud endpoint to transition objects to.

* Rename config option 'tier_storage_class' to 'target_storage_class'.

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

index 0552da0246268995da41fed3fd959fd6a173492b..b8c7675247caf80df6567360e3603467e9ba1010 100644 (file)
@@ -5573,6 +5573,10 @@ int main(int argc, const char **argv)
            cerr << "ERROR: storage class '" << storage_class << "' is not defined in zonegroup '" << placement_id << "' placement target" << std::endl;
            return EINVAL;
          }
+         if (ptiter->second.tier_targets.find(storage_class) != ptiter->second.tier_targets.end()) {
+           cerr << "ERROR: storage class '" << storage_class << "' is of tier type in zonegroup '" << placement_id << "' placement target" << std::endl;
+           return EINVAL;
+         }
 
           RGWZonePlacementInfo& info = zone.placement_pools[placement_id];
 
index df2f37c5e3a518358540796ac2d63d6ef9eb5a15..a2397bc35473ca416b4521f823d2d50149fe9ac4 100644 (file)
@@ -1458,7 +1458,7 @@ void RGWZoneGroupPlacementTier::dump(Formatter *f) const
   encode_json("secret", key.key, f);
   string s = (host_style == PathStyle ? "path" : "virtual");
   encode_json("host_style", s, f);
-  encode_json("tier_storage_class", tier_storage_class, f);
+  encode_json("target_storage_class", target_storage_class, f);
   encode_json("target_path", target_path, f);
   encode_json("acl_mappings", acl_mappings, f);
   encode_json("multipart_sync_threshold", multipart_sync_threshold, f);
@@ -1480,7 +1480,7 @@ void RGWZoneGroupPlacementTier::decode_json(JSONObj *obj)
   } else {
     host_style = VirtualStyle;
   }
-  JSONDecoder::decode_json("tier_storage_class", tier_storage_class, obj);
+  JSONDecoder::decode_json("target_storage_class", target_storage_class, obj);
   JSONDecoder::decode_json("target_path", target_path, obj);
   JSONDecoder::decode_json("acl_mappings", acl_mappings, obj);
   JSONDecoder::decode_json("multipart_sync_threshold", multipart_sync_threshold, obj);
@@ -1493,7 +1493,9 @@ void RGWZoneGroupPlacementTarget::dump(Formatter *f) const
   encode_json("name", name, f);
   encode_json("tags", tags, f);
   encode_json("storage_classes", storage_classes, f);
-  encode_json("tier_targets", tier_targets, f);
+  if (!tier_targets.empty()) {
+    encode_json("tier_targets", tier_targets, f);
+  }
 }
 
 void RGWZoneGroupPlacementTarget::decode_json(JSONObj *obj)
@@ -1504,7 +1506,9 @@ void RGWZoneGroupPlacementTarget::decode_json(JSONObj *obj)
   if (storage_classes.empty()) {
     storage_classes.insert(RGW_STORAGE_CLASS_STANDARD);
   }
-  JSONDecoder::decode_json("tier_targets", tier_targets, obj);
+  if (!tier_targets.empty()) {
+    JSONDecoder::decode_json("tier_targets", tier_targets, obj);
+  }
 }
 
 void RGWZoneGroup::dump(Formatter *f) const
index a5c36c9f4a9b048b55b20e33425ffc67c226d68d..d1625486712fd12f693bd69696c110edb6c33711 100644 (file)
@@ -1381,9 +1381,12 @@ public:
     RGWAccessKey key = oc.tier.key;
     HostStyle host_style = oc.tier.host_style;
     string bucket_name = oc.tier.target_path;
+    const RGWZoneGroup& zonegroup = oc.store->svc()->zone->get_zonegroup();
    
     if (bucket_name.empty()) {
-      bucket_name = "cloud-bucket";
+      bucket_name = "rgwx-" + zonegroup.get_name() + "-" + oc.tier.storage_class +
+                    "-cloud-bucket";
+      boost::algorithm::to_lower(bucket_name);
     }
 
     conn.reset(new S3RESTConn(oc.cct, oc.store->svc()->zone,
@@ -1400,7 +1403,7 @@ public:
     }
 
     RGWLCCloudTierCtx tier_ctx(oc.cct, oc.o, oc.store, oc.bucket_info,
-                        oc.obj, oc.rctx, conn, bucket_name, oc.tier.tier_storage_class,
+                        oc.obj, oc.rctx, conn, bucket_name, oc.tier.target_storage_class,
                         &http_manager);
     tier_ctx.acl_mappings = oc.tier.acl_mappings;
     tier_ctx.multipart_min_part_size = oc.tier.multipart_min_part_size;
@@ -1454,6 +1457,7 @@ public:
     target_placement.inherit_from(oc.bucket->get_placement_rule());
     target_placement.storage_class = transition.storage_class;
 
+    ldpp_dout(oc.dpp, 0) << "XXXXXXXXXXX ERROR: in lifecycle::process" <<  dendl;
     r = get_tier_target(zonegroup, target_placement, target_placement.storage_class, oc.tier);
 
     if (!r && oc.tier.tier_type == "cloud") {
index aa9c47ad40cfdad9f5f1499b4fce93b66b5e41b2..f842cfe929af7eb642e00c747d2b08e812acb3bc 100644 (file)
@@ -2114,8 +2114,8 @@ int RGWZoneGroupPlacementTier::update_params(const JSONFormattable& config)
       host_style = VirtualStyle;
     }
   }
-  if (config.exists("tier_storage_class")) {
-    tier_storage_class = config["tier_storage_class"];
+  if (config.exists("target_storage_class")) {
+    target_storage_class = config["target_storage_class"];
   }
   if (config.exists("access_key")) {
     key.id = config["access_key"];
@@ -2178,8 +2178,8 @@ int RGWZoneGroupPlacementTier::clear_params(const JSONFormattable& config)
     /* default */
     host_style = PathStyle;
   }
-  if (config.exists("tier_storage_class")) {
-    tier_storage_class.clear();
+  if (config.exists("target_storage_class")) {
+    target_storage_class.clear();
   }
   if (config.exists("access_key")) {
     key.id.clear();
index ab93a9c40e9857dce59554393c42bb1568e94975..c75a192b39136163c97f7da133a5af8c2364a705 100644 (file)
@@ -754,7 +754,7 @@ struct RGWZoneGroupPlacementTier {
   std::string endpoint;
   RGWAccessKey key;
   HostStyle host_style{PathStyle};
-  string tier_storage_class;
+  string target_storage_class;
 
   /* Should below be bucket/zone specific?? */
   string target_path;
@@ -776,7 +776,7 @@ struct RGWZoneGroupPlacementTier {
     encode(key, bl);
     string s = (host_style == PathStyle ? "path" : "virtual");
     encode(s, bl);
-    encode(tier_storage_class, bl);
+    encode(target_storage_class, bl);
     encode(target_path, bl);
     encode(acl_mappings, bl);
     encode(multipart_sync_threshold, bl);
@@ -798,7 +798,7 @@ struct RGWZoneGroupPlacementTier {
     } else {
       host_style = VirtualStyle;
     }
-    decode(tier_storage_class, bl);
+    decode(target_storage_class, bl);
     decode(target_path, bl);
     decode(acl_mappings, bl);
     decode(multipart_sync_threshold, bl);