]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Merge pull request #29515 from ivancich/wip-clean-up-reset-stats
authorCasey Bodley <cbodley@users.noreply.github.com>
Fri, 16 Aug 2019 14:21:02 +0000 (10:21 -0400)
committerGitHub <noreply@github.com>
Fri, 16 Aug 2019 14:21:02 +0000 (10:21 -0400)
rgw: housekeeping of reset stats operation in radosgw-admin and cls back-end

Reviewed-by: Casey Bodley <cbodley@redhat.com>
Reviewed-by: Abhishek Lekshmanan <abhishek@suse.com>
1  2 
src/rgw/rgw_admin.cc

index c983e5e59d97e591ae04de31863829e0b8398740,8fbf27b52006a9ae4d12588eb92aac84e09cc4bc..4613564fdc76852f7add9009aefa705390cab75d
@@@ -6808,29 -6752,32 +6808,37 @@@ next
        return EINVAL;
      }
  
 -    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);
 +      ret = store->ctl()->user->reset_stats(user_id);
        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;
        }
      }
  
      if (sync_stats) {
        if (!bucket_name.empty()) {
 -        int ret = rgw_bucket_sync_user_stats(store, tenant, bucket_name);
 +        RGWBucketInfo bucket_info;
 +        int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket);
 +        if (ret < 0) {
 +          cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
 +          return -ret;
 +        }
 +        ret = store->ctl()->bucket->sync_user_stats(user_id, bucket_info);
          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 {