]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add an rgw-admin option to clear usage stats for the cluster 19322/head
authorAbhishek Lekshmanan <abhishek@suse.com>
Mon, 4 Dec 2017 14:22:42 +0000 (15:22 +0100)
committerAbhishek Lekshmanan <abhishek@suse.com>
Mon, 8 Jan 2018 17:37:39 +0000 (18:37 +0100)
Add an option that can clear all the usage stats recorded so far, this
is more efficient than calling usage trim, since there we still have to
loop against individual keys and check whether they match our stats.
This is useful in use cases where usage data is already externally
backed up in some sort of time series data base in which case

Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
src/rgw/rgw_admin.cc
src/test/cli/radosgw-admin/help.t

index 03066016731305b67403c48ebba88dc3e2d46a2e..a510f6d4ea888c6012456aa469fc0e2e64764208 100644 (file)
@@ -163,6 +163,7 @@ void usage()
   cout << "  log rm                     remove log object\n";
   cout << "  usage show                 show usage (by user, date range)\n";
   cout << "  usage trim                 trim usage (by user, date range)\n";
+  cout << "  usage clear                reset all the usage stats for the cluster\n";
   cout << "  gc list                    dump expired garbage collection objects (specify\n";
   cout << "                             --include-all to list all entries, including unexpired)\n";
   cout << "  gc process                 manually process garbage (specify\n";
@@ -378,6 +379,7 @@ enum {
   OPT_LOG_RM,
   OPT_USAGE_SHOW,
   OPT_USAGE_TRIM,
+  OPT_USAGE_CLEAR,
   OPT_OBJECT_RM,
   OPT_OBJECT_UNLINK,
   OPT_OBJECT_STAT,
@@ -647,6 +649,8 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_
       return OPT_USAGE_SHOW;
     if (strcmp(cmd, "trim") == 0)
       return OPT_USAGE_TRIM;
+    if (strcmp(cmd, "clear") == 0)
+      return OPT_USAGE_CLEAR;
   } else if (strcmp(prev_cmd, "caps") == 0) {
     if (strcmp(cmd, "add") == 0)
       return OPT_CAPS_ADD;
@@ -5273,6 +5277,20 @@ next:
     }
   }
 
+  if (opt_cmd == OPT_USAGE_CLEAR) {
+    if (!yes_i_really_mean_it) {
+      cerr << "usage clear would remove *all* users usage data for all time" << std::endl;
+      cerr << "do you really mean it? (requires --yes-i-really-mean-it)" << std::endl;
+      return 1;
+    }
+
+    ret = RGWUsage::clear(store);
+    if (ret < 0) {
+      return ret;
+    }
+  }
+
+
   if (opt_cmd == OPT_OLH_GET || opt_cmd == OPT_OLH_READLOG) {
     if (bucket_name.empty()) {
       cerr << "ERROR: bucket not specified" << std::endl;
index b83b04841fd0a030f5f43dedaae1c0e83224ce6b..d4cf7f48467fa128d6ccd757b3bd10ebac102ac2 100644 (file)
     log rm                     remove log object
     usage show                 show usage (by user, date range)
     usage trim                 trim usage (by user, date range)
+    usage clear                reset all the usage stats for the cluster
     gc list                    dump expired garbage collection objects (specify
                                --include-all to list all entries, including unexpired)
     gc process                 manually process garbage (specify