From 58d7dfc994da604185720498093490d1de12348d Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 5 Sep 2019 02:26:33 -0700 Subject: [PATCH] rgw-admin: sync policy related commands Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_admin.cc | 20 ++++++++++++++++++++ src/rgw/rgw_bucket_sync.cc | 1 + src/rgw/rgw_sync_policy.h | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 6235964b182..b30113a5209 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -649,6 +649,8 @@ enum class OPT { MDLOG_STATUS, SYNC_ERROR_LIST, SYNC_ERROR_TRIM, + SYNC_POLICY_GET, + SYNC_POLICY_CONNECT, BILOG_LIST, BILOG_TRIM, BILOG_STATUS, @@ -3276,6 +3278,7 @@ int main(int argc, const char **argv) OPT::MDLOG_LIST, OPT::MDLOG_STATUS, OPT::SYNC_ERROR_LIST, + OPT::SYNC_POLICY_GET, OPT::BILOG_LIST, OPT::BILOG_STATUS, OPT::DATA_SYNC_STATUS, @@ -3298,6 +3301,7 @@ int main(int argc, const char **argv) OPT::RESHARD_STATUS, }; + bool raw_storage_op = (raw_storage_ops_list.find(opt_cmd) != raw_storage_ops_list.end() || raw_period_update); bool need_cache = readonly_ops_list.find(opt_cmd) == readonly_ops_list.end(); @@ -7526,6 +7530,22 @@ next: } } + if (opt_cmd == OPT::SYNC_POLICY_GET) { + RGWZoneGroup zonegroup(zonegroup_id, zonegroup_name); + ret = zonegroup.init(g_ceph_context, store->svc()->sysobj); + if (ret < 0) { + cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl; + return -ret; + } + + { + Formatter::ObjectSection os(*formatter, "result"); + encode_json("sync_policy", zonegroup.sync_policy, formatter); + } + + formatter->flush(cout); + } + if (opt_cmd == OPT::BILOG_TRIM) { if (bucket_name.empty()) { cerr << "ERROR: bucket not specified" << std::endl; diff --git a/src/rgw/rgw_bucket_sync.cc b/src/rgw/rgw_bucket_sync.cc index 61722627f23..92d70fff1cd 100644 --- a/src/rgw/rgw_bucket_sync.cc +++ b/src/rgw/rgw_bucket_sync.cc @@ -28,6 +28,7 @@ void RGWBucketSyncPolicyInfo::post_init() int RGWBucketSyncPolicyHandler::init() { const auto& zone_id = zone_svc->get_zone().id; + auto& zg = svc.zone->get_zonegroup(); if (!bucket_info.sync_policy) { return 0; diff --git a/src/rgw/rgw_sync_policy.h b/src/rgw/rgw_sync_policy.h index 4acbafb7255..0dbc3572d68 100644 --- a/src/rgw/rgw_sync_policy.h +++ b/src/rgw/rgw_sync_policy.h @@ -102,7 +102,8 @@ WRITE_CLASS_ENCODER(rgw_sync_source) struct rgw_sync_target { string id; string type; - std::vector flow_rules; /* flow rules for trivial sources */ + std::optional > flow_rules; /* flow rules for trivial sources, + if set then needs to be a subset of higher level rules */ std::set zones; /* target zones. Can be wildcard */ /* FIXME: add config */ -- 2.39.5