]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Merge pull request #28489 from croit/fix-40255
authorJ. Eric Ivancich <ivancich@redhat.com>
Thu, 3 Sep 2020 17:16:54 +0000 (13:16 -0400)
committerGitHub <noreply@github.com>
Thu, 3 Sep 2020 17:16:54 +0000 (13:16 -0400)
rgw: fix bucket limit check fill_status warnings

Reviewed-by: Matt Benjamin <mbenjamin@redhat.com>
Reviewed-by: Casey Bodley <cbodley@redhat.com>
1  2 
src/rgw/rgw_bucket.cc

index 68e011c73cec841ae015003c370bb0cccbcbe546,0af09dace64da22ee4ae0a71945379c806b3042d..aac26a0db037cd3b12746f0d8e5b1a0d75be1075
@@@ -1438,35 -1550,31 +1438,31 @@@ int RGWBucketAdminOp::limit_check(rgw::
          continue;
  
        for (const auto& s : stats) {
-           num_objects += s.second.num_objects;
+         num_objects += s.second.num_objects;
        }
  
 -      num_shards = info.num_shards;
 +      num_shards = info.layout.current_index.layout.normal.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);
 +          formatter->dump_string("bucket", bucket->get_name());
 +          formatter->dump_string("tenant", bucket->get_tenant());
            formatter->dump_int("num_objects", num_objects);
            formatter->dump_int("num_shards", num_shards);
            formatter->dump_int("objects_per_shard", objs_per_shard);