]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.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>
Fri, 12 Apr 2024 19:34:29 +0000 (15:34 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 333620c8f9ce1e3394e4a7c0d1274601d69dd943)

src/rgw/driver/rados/rgw_user.cc
src/rgw/rgw_admin.cc

index ee6e3157293cf19acb8c5ded062f1c05c0bb4f3d..79cbf74e6a97d628360b180f1f0f83e03baa37ed 100644 (file)
@@ -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;
index 420323f8328c19ce5a905f69d4237182a4d9c09b..497deed06f2aef1a8c2722e9b82aceb9b20196f3 100644 (file)
@@ -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;