rgw/CloudTransition: Do not allow data pool for tier type storage classes

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>
This commit is contained in:
Soumya Koduri 2020-12-14 23:56:16 +05:30
parent b86ba5d655
commit a3fdff29ea
5 changed files with 25 additions and 13 deletions

View 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];

View 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

View 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") {

View 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();

View 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);