From a8d33c081b8ff9303af91618e26b7d4ff64519ec Mon Sep 17 00:00:00 2001 From: weiqiaomiao Date: Sat, 4 Jun 2016 17:21:33 +0800 Subject: [PATCH] rgw: need to 'open_object_section' before dump stats in 'RGWGetUsage_ObjStore_S3::send_response()' function Fixes: http://tracker.ceph.com/issues/17499 Signed-off-by: weiqiaomiao --- PendingReleaseNotes | 18 ++++++++++++++++++ src/common/config_opts.h | 2 ++ src/rgw/rgw_rest_s3.cc | 12 +++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/PendingReleaseNotes b/PendingReleaseNotes index dd19f2a7342b..f842558f2670 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -17,6 +17,24 @@ listed in 'osd class default list' requires a capability naming the class (e.g. 'allow class foo'). +* The 'rgw rest getusage op compat' config option allows you to dump the description of user stats + or not in s3 GetUsage API. This config option is of bool type and defaults to false. + If the value is true, the reponse data of s3 GetUsage like below: + + "stats": { + "TotalBytes": 516, + "TotalBytesRounded": 1024, + "TotalEntries": 1 + } + + Or if the value is false, the reponse of s3 GetUsage like below and as it does before we add this config option: + + { + 516, + 1024, + 1 + }. + 11.0.0 ------ diff --git a/src/common/config_opts.h b/src/common/config_opts.h index b9cc870a8e1f..312b8edf36ba 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -1515,6 +1515,8 @@ OPTION(mon_mgr_beacon_grace, OPT_INT, 30) // How long to wait to failover OPTION(rgw_list_bucket_min_readahead, OPT_INT, 1000) // minimum number of entries to read from rados for bucket listing +OPTION(rgw_rest_getusage_op_compat, OPT_BOOL, false) // dump description of total stats for s3 GetUsage API + OPTION(mutex_perf_counter, OPT_BOOL, false) // enable/disable mutex perf counter OPTION(throttler_perf_counter, OPT_BOOL, true) // enable/disable throttler perf counter diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 629e619f8827..df16f7db6f87 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -430,10 +430,20 @@ void RGWGetUsage_ObjStore_S3::send_response() formatter->dump_int("SuccessfulOps", total_usage.successful_ops); formatter->close_section(); // total formatter->close_section(); // user - } + } + + if (s->cct->_conf->rgw_rest_getusage_op_compat) { + formatter->open_object_section("Stats"); + } + formatter->dump_int("TotalBytes", header.stats.total_bytes); formatter->dump_int("TotalBytesRounded", header.stats.total_bytes_rounded); formatter->dump_int("TotalEntries", header.stats.total_entries); + + if (s->cct->_conf->rgw_rest_getusage_op_compat) { + formatter->close_section(); //Stats + } + formatter->close_section(); // summary } formatter->close_section(); // usage -- 2.47.3