From: Casey Bodley Date: Thu, 15 Feb 2024 20:00:43 +0000 (-0500) Subject: rgw: 'user stats' redirects to 'account stats' X-Git-Tag: v19.1.0~99^2~63 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9e7fc8b9961f303e07ed7482c056b634b8c91fe9;p=ceph.git rgw: 'user stats' redirects to 'account stats' Signed-off-by: Casey Bodley (cherry picked from commit 333620c8f9ce1e3394e4a7c0d1274601d69dd943) --- diff --git a/src/rgw/driver/rados/rgw_user.cc b/src/rgw/driver/rados/rgw_user.cc index ee6e3157293c..79cbf74e6a97 100644 --- a/src/rgw/driver/rados/rgw_user.cc +++ b/src/rgw/driver/rados/rgw_user.cc @@ -2319,8 +2319,15 @@ int RGWUserAdminOp_User::info(const DoutPrefixProvider *dpp, ruser = driver->get_user(info.user_id); + rgw_owner owner = info.user_id; + if (!info.account_id.empty()) { + ldpp_dout(dpp, 4) << "Reading stats for user account " + << info.account_id << dendl; + owner = info.account_id; + } + if (op_state.sync_stats) { - ret = rgw_sync_all_stats(dpp, y, driver, ruser->get_id(), ruser->get_tenant()); + ret = rgw_sync_all_stats(dpp, y, driver, owner, ruser->get_tenant()); if (ret < 0) { return ret; } @@ -2331,7 +2338,7 @@ int RGWUserAdminOp_User::info(const DoutPrefixProvider *dpp, if (op_state.fetch_stats) { ceph::real_time last_synced; // ignored ceph::real_time last_updated; // ignored - int ret = driver->load_stats(dpp, y, ruser->get_id(), stats, + int ret = driver->load_stats(dpp, y, owner, stats, last_synced, last_updated); if (ret < 0 && ret != -ENOENT) { return ret; diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 420323f8328c..497deed06f2a 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -9055,12 +9055,25 @@ next: } } + int ret = user->load_user(dpp(), null_yield); + if (ret < 0) { + cerr << "User has not been initialized or user does not exist" << std::endl; + return -ret; + } + + const RGWUserInfo& info = user->get_info(); + rgw_owner owner = info.user_id; + if (!info.account_id.empty()) { + cerr << "Reading stats for user account " << info.account_id << std::endl; + owner = info.account_id; + } + constexpr bool omit_utilized_stats = false; RGWStorageStats stats(omit_utilized_stats); ceph::real_time last_stats_sync; ceph::real_time last_stats_update; - int ret = driver->load_stats(dpp(), null_yield, user->get_id(), - stats, last_stats_sync, last_stats_update); + ret = driver->load_stats(dpp(), null_yield, owner, stats, + last_stats_sync, last_stats_update); if (ret < 0) { if (ret == -ENOENT) { /* in case of ENOENT */ cerr << "User has not been initialized or user does not exist" << std::endl;