From: Paul Emmerich Date: Tue, 11 Jun 2019 12:10:55 +0000 (+0200) Subject: rgw: fix bucket limit check fill_status warnings X-Git-Tag: v14.2.17~84^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=dffe136ffec716899120f46b79a7fb674ab849cb;p=ceph.git rgw: fix bucket limit check fill_status warnings 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 (cherry picked from commit 694076419e6f20d1ed6c95b4b1ff94f134a10d4d) --- diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index e7ebfeefa2ce9..f51c2a8b84a33 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -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);