Skip to content

Commit

Permalink
rgw/CloudTransition: Do not allow data pool for tier type storage cla…
Browse files Browse the repository at this point in the history
…sses

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 <[email protected]>
  • Loading branch information
soumyakoduri committed Nov 18, 2021
1 parent b86ba5d commit a3fdff2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
4 changes: 4 additions & 0 deletions src/rgw/rgw_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
12 changes: 8 additions & 4 deletions src/rgw/rgw_json_enc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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)
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/rgw/rgw_lc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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") {
Expand Down
8 changes: 4 additions & 4 deletions src/rgw/rgw_zone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/rgw/rgw_zone.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit a3fdff2

Please sign in to comment.