]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: allow zone[group] modify to configure index shards
authorCasey Bodley <cbodley@redhat.com>
Wed, 15 Jan 2020 20:44:48 +0000 (15:44 -0500)
committerCasey Bodley <cbodley@redhat.com>
Thu, 27 Feb 2020 20:12:22 +0000 (15:12 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
doc/man/8/radosgw-admin.rst
src/rgw/rgw_admin.cc
src/rgw/rgw_zone.cc
src/rgw/rgw_zone.h
src/test/cli/radosgw-admin/help.t

index 6cf1f1100832a9932becd1f07f28a57048230c2a..27569fa53e21eb0913871c58dec616305b7aa22f 100644 (file)
@@ -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.
index 56560064fdb371085b48f8677653bb885f51a382..a38bfd1e8bbacb9f29dbd388b37d78bcccc9fa72 100644 (file)
@@ -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<int> 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;
index ac2d8ab6fb145a313aa7994dde630ca87a75dea5..e28c2c9804c5206cbe468c39a95c505a0e67f934 100644 (file)
@@ -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<string>& endpoints, const string *ptier_type,
                            bool *psync_from_all, list<string>& sync_from, list<string>& sync_from_rm,
-                           string *predirect_zone, RGWSyncModulesManager *sync_mgr)
+                           string *predirect_zone, std::optional<int> 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);
   }
index 1837b4f4f7d65bac575757a2ba4c55d36d4ac6a4..090c3e3c3061828b613fd56167b711d65a528ec2 100644 (file)
@@ -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<std::string>& endpoints, const std::string *ptier_type,
-               bool *psync_from_all, list<std::string>& sync_from, list<std::string>& sync_from_rm,
-               std::string *predirect_zone, RGWSyncModulesManager *sync_mgr);
+               bool *psync_from_all, list<std::string>& sync_from,
+               list<std::string>& sync_from_rm, std::string *predirect_zone,
+               std::optional<int> 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;
index b41caf193898218f238d837a0908faf6279a2b51..4f2e1bfc85e0bc3050ab9d03940ecb2ce6f26e2c 100644 (file)
                                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