Merge pull request #52445 from soumyakoduri/wip-skoduri-syncpolicy-fixes

rgw/sync-policy: Correct "sync status" & "sync group" commands

Reviewed-by: Casey Bodley <cbodley@redhat.com>
This commit is contained in:
Soumya Koduri 2023-07-23 23:11:14 +05:30 committed by GitHub
commit 01bc98b489
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 11 deletions

View File

@ -2255,7 +2255,7 @@ static void get_data_sync_status(const rgw_zone_id& source_zone, list<string>& s
return;
}
if (!static_cast<rgw::sal::RadosStore*>(driver)->svc()->zone->zone_syncs_from(static_cast<rgw::sal::RadosStore*>(driver)->svc()->zone->get_zone(), *sz)) {
if (!static_cast<rgw::sal::RadosStore*>(driver)->svc()->zone->zone_syncs_from(*sz)) {
push_ss(ss, status, tab) << string("not syncing from zone");
flush_ss(ss, status);
return;
@ -9490,7 +9490,7 @@ next:
if (opt_cmd == OPT::SYNC_GROUP_CREATE ||
opt_cmd == OPT::SYNC_GROUP_MODIFY) {
CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL);
CHECK_TRUE(require_non_empty_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL);
CHECK_TRUE(require_opt(opt_status), "ERROR: --status is not specified (options: forbidden, allowed, enabled)", EINVAL);
SyncPolicyContext sync_policy_ctx(cfgstore.get(), opt_bucket);
@ -9550,7 +9550,7 @@ next:
}
if (opt_cmd == OPT::SYNC_GROUP_REMOVE) {
CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL);
CHECK_TRUE(require_non_empty_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL);
SyncPolicyContext sync_policy_ctx(cfgstore.get(), opt_bucket);
ret = sync_policy_ctx.init(zonegroup_id, zonegroup_name);
@ -9575,8 +9575,8 @@ next:
}
if (opt_cmd == OPT::SYNC_GROUP_FLOW_CREATE) {
CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL);
CHECK_TRUE(require_opt(opt_flow_id), "ERROR: --flow-id not specified", EINVAL);
CHECK_TRUE(require_non_empty_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL);
CHECK_TRUE(require_non_empty_opt(opt_flow_id), "ERROR: --flow-id not specified", EINVAL);
CHECK_TRUE(require_opt(opt_flow_type),
"ERROR: --flow-type not specified (options: symmetrical, directional)", EINVAL);
CHECK_TRUE((symmetrical_flow_opt(*opt_flow_type) ||
@ -9626,8 +9626,8 @@ next:
}
if (opt_cmd == OPT::SYNC_GROUP_FLOW_REMOVE) {
CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL);
CHECK_TRUE(require_opt(opt_flow_id), "ERROR: --flow-id not specified", EINVAL);
CHECK_TRUE(require_non_empty_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL);
CHECK_TRUE(require_non_empty_opt(opt_flow_id), "ERROR: --flow-id not specified", EINVAL);
CHECK_TRUE(require_opt(opt_flow_type),
"ERROR: --flow-type not specified (options: symmetrical, directional)", EINVAL);
CHECK_TRUE((symmetrical_flow_opt(*opt_flow_type) ||
@ -9668,8 +9668,8 @@ next:
if (opt_cmd == OPT::SYNC_GROUP_PIPE_CREATE ||
opt_cmd == OPT::SYNC_GROUP_PIPE_MODIFY) {
CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL);
CHECK_TRUE(require_opt(opt_pipe_id), "ERROR: --pipe-id not specified", EINVAL);
CHECK_TRUE(require_non_empty_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL);
CHECK_TRUE(require_non_empty_opt(opt_pipe_id), "ERROR: --pipe-id not specified", EINVAL);
if (opt_cmd == OPT::SYNC_GROUP_PIPE_CREATE) {
CHECK_TRUE(require_non_empty_opt(opt_source_zone_ids), "ERROR: --source-zones not provided or is empty; should be list of zones or '*'", EINVAL);
CHECK_TRUE(require_non_empty_opt(opt_dest_zone_ids), "ERROR: --dest-zones not provided or is empty; should be list of zones or '*'", EINVAL);
@ -9754,8 +9754,8 @@ next:
}
if (opt_cmd == OPT::SYNC_GROUP_PIPE_REMOVE) {
CHECK_TRUE(require_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL);
CHECK_TRUE(require_opt(opt_pipe_id), "ERROR: --pipe-id not specified", EINVAL);
CHECK_TRUE(require_non_empty_opt(opt_group_id), "ERROR: --group-id not specified", EINVAL);
CHECK_TRUE(require_non_empty_opt(opt_pipe_id), "ERROR: --pipe-id not specified", EINVAL);
SyncPolicyContext sync_policy_ctx(cfgstore.get(), opt_bucket);
ret = sync_policy_ctx.init(zonegroup_id, zonegroup_name);

View File

@ -65,6 +65,21 @@ bool RGWSI_Zone::zone_syncs_from(const RGWZone& target_zone, const RGWZone& sour
sync_modules_svc->get_manager()->supports_data_export(source_zone.tier_type);
}
bool RGWSI_Zone::zone_syncs_from(const RGWZone& source_zone) const
{
auto target_zone = get_zone();
bool found = false;
for (auto s : data_sync_source_zones) {
if (s->id == source_zone.id) {
found = true;
break;
}
}
return found && target_zone.syncs_from(source_zone.name) &&
sync_modules_svc->get_manager()->supports_data_export(source_zone.tier_type);
}
int RGWSI_Zone::search_realm_with_zone(const DoutPrefixProvider *dpp,
const rgw_zone_id& zid,
RGWRealm *prealm,

View File

@ -103,6 +103,7 @@ public:
bool zone_is_writeable();
bool zone_syncs_from(const RGWZone& target_zone, const RGWZone& source_zone) const;
bool zone_syncs_from(const RGWZone& source_zone) const;
bool get_redirect_zone_endpoint(std::string *endpoint);
bool sync_module_supports_writes() const { return writeable_zone; }
bool sync_module_exports_data() const { return exports_data; }