]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: clean-up error handling with rgw-admin --reset-stats
authorJ. Eric Ivancich <ivancich@redhat.com>
Tue, 6 Aug 2019 20:12:01 +0000 (16:12 -0400)
committerJ. Eric Ivancich <ivancich@redhat.com>
Wed, 7 Aug 2019 13:40:02 +0000 (09:40 -0400)
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>
src/rgw/rgw_admin.cc

index e652ec5618c9afb267524791e7db50b75ed6009e..8fbf27b52006a9ae4d12588eb92aac84e09cc4bc 100644 (file)
@@ -6754,13 +6754,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;
       }
     }
@@ -6769,13 +6776,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;
         }
       }