]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix bucket limit check fill_status warnings 38825/head
authorPaul Emmerich <paul.emmerich@croit.io>
Tue, 11 Jun 2019 12:10:55 +0000 (14:10 +0200)
committerNathan Cutler <ncutler@suse.com>
Fri, 8 Jan 2021 18:05:32 +0000 (19:05 +0100)
all variables in the calculation where ints, so the warning would
only ever trigger if objects_per_shard == limit_objects and the
percentage for > 100% used a granularity of 100%

Fixes: http://tracker.ceph.com/issues/40255
Signed-off-by: Paul Emmerich <paul.emmerich@croit.io>
(cherry picked from commit 694076419e6f20d1ed6c95b4b1ff94f134a10d4d)

src/rgw/rgw_bucket.cc

index e7ebfeefa2ce974e8f10fdbefc239b5b52d14e7e..f51c2a8b84a33e88b5b99d7fb947b649b976234c 100644 (file)
@@ -1589,32 +1589,28 @@ int RGWBucketAdminOp::limit_check(RGWRados *store,
          continue;
 
        for (const auto& s : stats) {
-           num_objects += s.second.num_objects;
+         num_objects += s.second.num_objects;
        }
 
        num_shards = info.num_shards;
        uint64_t objs_per_shard =
          (num_shards) ? num_objects/num_shards : num_objects;
        {
-         bool warn = false;
+         bool warn;
          stringstream ss;
-         if (objs_per_shard > safe_max_objs_per_shard) {
-           double over =
-             100 - (safe_max_objs_per_shard/objs_per_shard * 100);
-             ss << boost::format("OVER %4f%%") % over;
-             warn = true;
+         uint64_t fill_pct = objs_per_shard * 100 / safe_max_objs_per_shard;
+         if (fill_pct > 100) {
+           ss << "OVER " << fill_pct << "%";
+           warn = true;
+         } else if (fill_pct >= shard_warn_pct) {
+           ss << "WARN " << fill_pct << "%";
+           warn = true;
          } else {
-           double fill_pct =
-             objs_per_shard / safe_max_objs_per_shard * 100;
-           if (fill_pct >= shard_warn_pct) {
-             ss << boost::format("WARN %4f%%") % fill_pct;
-             warn = true;
-           } else {
-             ss << "OK";
-           }
+           ss << "OK";
+           warn = false;
          }
 
-         if (warn || (! warnings_only)) {
+         if (warn || !warnings_only) {
            formatter->open_object_section("bucket");
            formatter->dump_string("bucket", bucket.name);
            formatter->dump_string("tenant", bucket.tenant);