From 333620c8f9ce1e3394e4a7c0d1274601d69dd943 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 15 Feb 2024 15:00:43 -0500 Subject: [PATCH] rgw: 'user stats' redirects to 'account stats' Signed-off-by: Casey Bodley --- src/rgw/driver/rados/rgw_user.cc | 11 +++++++++-- src/rgw/rgw_admin.cc | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/rgw/driver/rados/rgw_user.cc b/src/rgw/driver/rados/rgw_user.cc index 8af0947560ef0..9bc095de3563f 100644 --- a/src/rgw/driver/rados/rgw_user.cc +++ b/src/rgw/driver/rados/rgw_user.cc @@ -2323,8 +2323,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; } @@ -2335,7 +2342,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 17edcd57efd56..88ad789efd7fa 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -9062,12 +9062,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; -- 2.39.5