diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 0552da0246268..b8c7675247caf 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -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]; diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index df2f37c5e3a51..a2397bc35473c 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -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 diff --git a/src/rgw/rgw_lc.cc b/src/rgw/rgw_lc.cc index a5c36c9f4a9b0..d1625486712fd 100644 --- a/src/rgw/rgw_lc.cc +++ b/src/rgw/rgw_lc.cc @@ -1381,9 +1381,12 @@ class LCOpAction_Transition : public LCOpAction { 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 @@ class LCOpAction_Transition : public LCOpAction { } 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 @@ class LCOpAction_Transition : public LCOpAction { 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") { diff --git a/src/rgw/rgw_zone.cc b/src/rgw/rgw_zone.cc index aa9c47ad40cfd..f842cfe929af7 100644 --- a/src/rgw/rgw_zone.cc +++ b/src/rgw/rgw_zone.cc @@ -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(); diff --git a/src/rgw/rgw_zone.h b/src/rgw/rgw_zone.h index ab93a9c40e985..c75a192b39136 100644 --- a/src/rgw/rgw_zone.h +++ b/src/rgw/rgw_zone.h @@ -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);