From: Casey Bodley Date: Wed, 15 Jan 2020 20:44:48 +0000 (-0500) Subject: radosgw-admin: allow zone[group] modify to configure index shards X-Git-Tag: v15.1.1~171^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f57bf023707f73b6543604a711ac7c234620c412;p=ceph.git radosgw-admin: allow zone[group] modify to configure index shards Signed-off-by: Casey Bodley --- diff --git a/doc/man/8/radosgw-admin.rst b/doc/man/8/radosgw-admin.rst index 6cf1f1100832..27569fa53e21 100644 --- a/doc/man/8/radosgw-admin.rst +++ b/doc/man/8/radosgw-admin.rst @@ -728,6 +728,13 @@ Options Remove the zones from list of zones to sync from. +.. option:: --bucket-index-max-shards + + Override a zone's or zonegroup's default number of bucket index shards. This + option is accepted by the 'zone create', 'zone modify', 'zonegroup add', + and 'zonegroup modify' commands, and applies to buckets that are created + after the zone/zonegroup changes take effect. + .. option:: --fix Besides checking bucket index, will also fix it. diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 56560064fdb3..a38bfd1e8bba 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -350,6 +350,7 @@ void usage() cout << " set list of zones to sync from\n"; cout << " --sync-from-rm=[zone-name][,...]\n"; cout << " remove zones from list of zones to sync from\n"; + cout << " --bucket-index-max-shards override a zone/zonegroup's default bucket index shard count\n"; cout << " --fix besides checking bucket index, will also fix it\n"; cout << " --check-objects bucket check: rebuilds bucket index according to\n"; cout << " actual objects state\n"; @@ -3157,6 +3158,7 @@ int main(int argc, const char **argv) string job_id; int num_shards = 0; bool num_shards_specified = false; + std::optional bucket_index_max_shards; int max_concurrent_ios = 32; uint64_t orphan_stale_secs = (24 * 3600); int detail = false; @@ -3360,6 +3362,12 @@ int main(int argc, const char **argv) return EINVAL; } num_shards_specified = true; + } else if (ceph_argparse_witharg(args, i, &val, "--bucket-index-max-shards", (char*)NULL)) { + bucket_index_max_shards = (int)strict_strtol(val.c_str(), 10, &err); + if (!err.empty()) { + cerr << "ERROR: failed to parse bucket-index-max-shards: " << err << std::endl; + return EINVAL; + } } else if (ceph_argparse_witharg(args, i, &val, "--max-concurrent-ios", (char*)NULL)) { max_concurrent_ios = (int)strict_strtol(val.c_str(), 10, &err); if (!err.empty()) { @@ -4435,7 +4443,7 @@ int main(int argc, const char **argv) (is_read_only_set ? &read_only : NULL), endpoints, ptier_type, psync_from_all, sync_from, sync_from_rm, - predirect_zone, + predirect_zone, bucket_index_max_shards, store->svc()->sync_modules->get_manager()); if (ret < 0) { cerr << "failed to add zone " << zone_name << " to zonegroup " << zonegroup.get_name() << ": " @@ -4611,6 +4619,13 @@ int main(int argc, const char **argv) need_update = true; } + if (bucket_index_max_shards) { + for (auto& [name, zone] : zonegroup.zones) { + zone.bucket_index_max_shards = *bucket_index_max_shards; + } + need_update = true; + } + if (need_update) { ret = zonegroup.update(); if (ret < 0) { @@ -4905,7 +4920,7 @@ int main(int argc, const char **argv) ptier_type, psync_from_all, sync_from, sync_from_rm, - predirect_zone, + predirect_zone, bucket_index_max_shards, store->svc()->sync_modules->get_manager()); if (ret < 0) { cerr << "failed to add zone " << zone_name << " to zonegroup " << zonegroup.get_name() @@ -5188,7 +5203,7 @@ int main(int argc, const char **argv) (is_read_only_set ? &read_only : NULL), endpoints, ptier_type, psync_from_all, sync_from, sync_from_rm, - predirect_zone, + predirect_zone, bucket_index_max_shards, store->svc()->sync_modules->get_manager()); if (ret < 0) { cerr << "failed to update zonegroup: " << cpp_strerror(-ret) << std::endl; diff --git a/src/rgw/rgw_zone.cc b/src/rgw/rgw_zone.cc index ac2d8ab6fb14..e28c2c9804c5 100644 --- a/src/rgw/rgw_zone.cc +++ b/src/rgw/rgw_zone.cc @@ -179,7 +179,8 @@ int RGWZoneGroup::equals(const string& other_zonegroup) const int RGWZoneGroup::add_zone(const RGWZoneParams& zone_params, bool *is_master, bool *read_only, const list& endpoints, const string *ptier_type, bool *psync_from_all, list& sync_from, list& sync_from_rm, - string *predirect_zone, RGWSyncModulesManager *sync_mgr) + string *predirect_zone, std::optional bucket_index_max_shards, + RGWSyncModulesManager *sync_mgr) { auto& zone_id = zone_params.get_id(); auto& zone_name = zone_params.get_name(); @@ -234,6 +235,10 @@ int RGWZoneGroup::add_zone(const RGWZoneParams& zone_params, bool *is_master, bo zone.redirect_zone = *predirect_zone; } + if (bucket_index_max_shards) { + zone.bucket_index_max_shards = *bucket_index_max_shards; + } + for (auto add : sync_from) { zone.sync_from.insert(add); } diff --git a/src/rgw/rgw_zone.h b/src/rgw/rgw_zone.h index 1837b4f4f7d6..090c3e3c3061 100644 --- a/src/rgw/rgw_zone.h +++ b/src/rgw/rgw_zone.h @@ -799,8 +799,9 @@ struct RGWZoneGroup : public RGWSystemMetaObj { int equals(const std::string& other_zonegroup) const; int add_zone(const RGWZoneParams& zone_params, bool *is_master, bool *read_only, const list& endpoints, const std::string *ptier_type, - bool *psync_from_all, list& sync_from, list& sync_from_rm, - std::string *predirect_zone, RGWSyncModulesManager *sync_mgr); + bool *psync_from_all, list& sync_from, + list& sync_from_rm, std::string *predirect_zone, + std::optional bucket_index_max_shards, RGWSyncModulesManager *sync_mgr); int remove_zone(const std::string& zone_id); int rename_zone(const RGWZoneParams& zone_params); rgw_pool get_pool(CephContext *cct) const override; diff --git a/src/test/cli/radosgw-admin/help.t b/src/test/cli/radosgw-admin/help.t index b41caf193898..4f2e1bfc85e0 100644 --- a/src/test/cli/radosgw-admin/help.t +++ b/src/test/cli/radosgw-admin/help.t @@ -245,6 +245,7 @@ set list of zones to sync from --sync-from-rm=[zone-name][,...] remove zones from list of zones to sync from + --bucket-index-max-shards override a zone/zonegroup's default bucket index shard count --fix besides checking bucket index, will also fix it --check-objects bucket check: rebuilds bucket index according to actual objects state