]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: 'user stats' redirects to 'account stats'
authorCasey Bodley <cbodley@redhat.com>
Thu, 15 Feb 2024 20:00:43 +0000 (15:00 -0500)
committerCasey Bodley <cbodley@redhat.com>
Wed, 10 Apr 2024 17:09:16 +0000 (13:09 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/driver/rados/rgw_user.cc
src/rgw/rgw_admin.cc

index 8af0947560ef09b5c8c4248895337b686403c29a..9bc095de3563fba0c68e4e7c06baa9a2914b2924 100644 (file)
@@ -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;
index 17edcd57efd569517b545498288d09b0feb16786..88ad789efd7faaf9ce069d85f258fa4fa68e1cac 100644 (file)
@@ -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;