]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: admin api - add ability to sync user stats from admin api 17589/head
authorNathan Johnson <njohnson@ena.com>
Fri, 8 Sep 2017 04:27:40 +0000 (23:27 -0500)
committerNathan Johnson <njohnson@ena.com>
Fri, 8 Sep 2017 15:31:54 +0000 (10:31 -0500)
Fixes: http://tracker.ceph.com/issues/21301
Signed-off-by: Nathan Johnson <nathan@nathanjohnson.org>
src/rgw/rgw_rest_user.cc
src/rgw/rgw_user.cc
src/rgw/rgw_user.h

index 8539c3ed766409a923b70e836b88a1429e68d0b8..c8d8dd74265c8ed116d53699d65e717d2deb7c87 100644 (file)
@@ -32,6 +32,7 @@ void RGWOp_User_Info::execute()
 
   std::string uid_str;
   bool fetch_stats;
+  bool sync_stats;
 
   RESTArgs::get_string(s, "uid", uid_str, &uid_str);
 
@@ -47,8 +48,11 @@ void RGWOp_User_Info::execute()
 
   RESTArgs::get_bool(s, "stats", false, &fetch_stats);
 
+  RESTArgs::get_bool(s, "sync", false, &sync_stats);
+
   op_state.set_user_id(uid);
   op_state.set_fetch_stats(fetch_stats);
+  op_state.set_sync_stats(sync_stats);
 
   http_ret = RGWUserAdminOp_User::info(store, op_state, flusher);
 }
index ebe795e7d6f6bb5deac831d4d87000ce9171b96d..a14e19c37db01a8e87244e6a4452672ad62ed2e8 100644 (file)
@@ -2363,6 +2363,13 @@ int RGWUserAdminOp_User::info(RGWRados *store, RGWUserAdminOpState& op_state,
   if (ret < 0)
     return ret;
 
+  if (op_state.sync_stats) {
+    ret = rgw_user_sync_all_stats(store, info.user_id);
+    if (ret < 0) {
+      return ret;
+    }
+  }
+
   RGWStorageStats stats;
   RGWStorageStats *arg_stats = NULL;
   if (op_state.fetch_stats) {
index 5e6754b0380ccee2fef8fc5a7f0af8e5311b7a51..516617a295574c985bcee22c3bbbca60de174569 100644 (file)
@@ -163,6 +163,7 @@ struct RGWUserAdminOpState {
   __u8 system;
   __u8 exclusive;
   __u8 fetch_stats;
+  __u8 sync_stats;
   std::string caps;
   RGWObjVersionTracker objv;
   uint32_t op_mask;
@@ -334,6 +335,10 @@ struct RGWUserAdminOpState {
     fetch_stats = is_fetch_stats;
   }
 
+  void set_sync_stats(__u8 is_sync_stats) {
+    sync_stats = is_sync_stats;
+  }
+
   void set_user_info(RGWUserInfo& user_info) {
     user_id = user_info.user_id;
     info = user_info;