Merge pull request #28489 from croit/fix-40255

rgw: fix bucket limit check fill_status warnings

Reviewed-by: Matt Benjamin <mbenjamin@redhat.com>
Reviewed-by: Casey Bodley <cbodley@redhat.com>
This commit is contained in:
J. Eric Ivancich 2020-09-03 13:16:54 -04:00 committed by GitHub
commit 9d7d622b61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1438,32 +1438,28 @@ int RGWBucketAdminOp::limit_check(rgw::sal::RGWRadosStore *store,
continue;
for (const auto& s : stats) {
num_objects += s.second.num_objects;
num_objects += s.second.num_objects;
}
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->get_name());
formatter->dump_string("tenant", bucket->get_tenant());