]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: clean-up error handling with rgw-admin --reset-stats 30165/head
authorJ. Eric Ivancich <ivancich@redhat.com>
Tue, 6 Aug 2019 20:12:01 +0000 (16:12 -0400)
committerNathan Cutler <ncutler@suse.com>
Thu, 5 Sep 2019 08:12:25 +0000 (10:12 +0200)
Made error messages more consistent. Errored out when --reset-stats
was used in conjunction with --sync-stats since the latter does a
superset of the former.

Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
(cherry picked from commit 0a830596a3ea3845e467a1c60df7e9f39c0579b1)

src/rgw/rgw_admin.cc

index 81fd13ef55c3e0ebc84c12b48f470ae5a3eed483..83de55654cc1a47e78fceb403112afb38c6ec721 100644 (file)
@@ -6569,13 +6569,20 @@ next:
 
     string user_str = user_id.to_str();
     if (reset_stats) {
-      if (!bucket_name.empty()){
-       cerr << "ERROR: recalculate doesn't work on buckets" << std::endl;
+      if (!bucket_name.empty()) {
+       cerr << "ERROR: --reset-stats does not work on buckets and "
+         "bucket specified" << std::endl;
+       return EINVAL;
+      }
+      if (sync_stats) {
+       cerr << "ERROR: sync-stats includes the reset-stats functionality, "
+         "so at most one of the two should be specified" << std::endl;
        return EINVAL;
       }
       ret = store->cls_user_reset_stats(user_str);
       if (ret < 0) {
-       cerr << "ERROR: could not clear user stats: " << cpp_strerror(-ret) << std::endl;
+       cerr << "ERROR: could not reset user stats: " << cpp_strerror(-ret) <<
+         std::endl;
        return -ret;
       }
     }
@@ -6584,13 +6591,15 @@ next:
       if (!bucket_name.empty()) {
         int ret = rgw_bucket_sync_user_stats(store, tenant, bucket_name);
         if (ret < 0) {
-          cerr << "ERROR: could not sync bucket stats: " << cpp_strerror(-ret) << std::endl;
+          cerr << "ERROR: could not sync bucket stats: " <<
+           cpp_strerror(-ret) << std::endl;
           return -ret;
         }
       } else {
         int ret = rgw_user_sync_all_stats(store, user_id);
         if (ret < 0) {
-          cerr << "ERROR: failed to sync user stats: " << cpp_strerror(-ret) << std::endl;
+          cerr << "ERROR: could not sync user stats: " <<
+           cpp_strerror(-ret) << std::endl;
           return -ret;
         }
       }